Microsoft Blend for Visual Studio and Unity workflow
What is your current workflow when using the current version of Microsoft Blend for Visual Studio? The "Link to Existing Item..." option is no longer available.
The documentation here is using the old Microsoft Expression Blend 4 version.
I prefer coding my XAML but use the designer to see how it looks. The designer in Visual Studio gives me exceptions.
P.S. I pretty much read all forum posts and do not remember seeing anything about this, and I cannot perform a search because the search function complains about "blend" and "visual studio" being too common.
The documentation here is using the old Microsoft Expression Blend 4 version.
I prefer coding my XAML but use the designer to see how it looks. The designer in Visual Studio gives me exceptions.
P.S. I pretty much read all forum posts and do not remember seeing anything about this, and I cannot perform a search because the search function complains about "blend" and "visual studio" being too common.
Last edited by kguner on 05 Nov 2015, 21:00, edited 1 time in total.
Re: Microsoft Blend for Visual Studio and Unity workflow
I just checked, and to link to a XAML file in the latest Visual Studio versions you must select "Add > Existing Item..."
See this screenshot:
The Visual Studio project created by Unity (more specifically the UnityEngine library it references) is not compatible with the libraries which are required before you can visually edit XAML files in the designer.
In order to use the designer create a new "WPF Application" and add the XAML files (which should still be located within the Assets folder of your Unity project) there using "Add > Existing Item...". You can then view and edit these XAML files in the designer.
I hope that helps.
See this screenshot:
The Visual Studio project created by Unity (more specifically the UnityEngine library it references) is not compatible with the libraries which are required before you can visually edit XAML files in the designer.
In order to use the designer create a new "WPF Application" and add the XAML files (which should still be located within the Assets folder of your Unity project) there using "Add > Existing Item...". You can then view and edit these XAML files in the designer.
I hope that helps.
Re: Microsoft Blend for Visual Studio and Unity workflow
Add Existing Item will copy the file if the file system folder structure doesn't match Blend's project folder structure. If the files are copies you're going to have a hard time syncing Unity with Blend. To prevent that you have to be careful how you set-up the projects.
For the folder structure there are several options:
When you have merged the Unity and Blend projects using one of the options above, you still have to avoid the Add Existing Item action.
Now the UserControls that Blend creates are not directly compatible with Unity. In the other direction, Blend does not recognize Noesis classes out of the box.
For the folder structure there are several options:
- Create a new Blend project. Check "Create directory for solution". Create a folder named Assets under the project folder. Now you can open the project folder in Unity.
The folder structure will look like this:
SolutionName
-- SolutionName.sln (created by Blend)
-- WpfApplication1
---- WpfApplication1.sln (created by UnityVS)
---- Assets
------ MVVM
-------- ViewModels
-------- Views - You could uncheck "Create directory for solution" to flatten the folder structure by one level, but then you have to rename the solution file that Blend created or it will be overwritten by Unity.
WpfApplication1
-- WpfApplication1Blend.sln (created by Blend, renamed by user)
-- WpfApplication1.sln (created by UnityVS)
-- Assets
---- MVVM
------ ViewModels
------ Views - Create a new Unity project. Above the Assets folder start a new Blend project. Within the Assets folder put all your XAML stuff that belongs together in a single folder. Then create a symlink or junction from that folder to the Blend project folder.
MyUnityProject
-- Assets
---- MVVM
------- ViewModels
------- Views
-- BlendMyUnityProject
---- MVVM (= Symlink/Junction to Assets/MVVM folder)
When you have merged the Unity and Blend projects using one of the options above, you still have to avoid the Add Existing Item action.
- You can add existing files to the Blend project file by revealing the folder structure by pressing the Show All Files button, selecting the files and executing the Include In Project context menu action.
- When you create new files in Blend, you also have to be aware of the underlying hidden folder structure. Again, enable Show All Files and remember to be able open the files in Unity they have to be under the Assets folder.
Now the UserControls that Blend creates are not directly compatible with Unity. In the other direction, Blend does not recognize Noesis classes out of the box.
- You could create some dummy classes and store them in a separate reusable project
- Use preprocessor directives (#if UNITY_5 ... #else ... #endif)
- Create Blend templates that work with Noesis instead of using the default ones
Re: Microsoft Blend for Visual Studio and Unity workflow
Great response Movra, thank you.
Re: Microsoft Blend for Visual Studio and Unity workflow
Ah apologies, I did not realise that using Add Existing Item copied the file.
There is another solution which will allow you to link all of your XAML files without moving them.
Open the WPF project file (.csproj) in a text editor, and add the following ItemGroup entry:
<ItemGroup>
<None Include="Path\To\Your\XAML\**\*.xaml">
<Link>XAML\%(RecursiveDir)%(FileName)%(Extension)</Link>
</None>
</ItemGroup>
Each time you load the project it will automatically link all XAML files found in the Path\To\Your\XAML\ directory. This is the method I use.
There is another solution which will allow you to link all of your XAML files without moving them.
Open the WPF project file (.csproj) in a text editor, and add the following ItemGroup entry:
<ItemGroup>
<None Include="Path\To\Your\XAML\**\*.xaml">
<Link>XAML\%(RecursiveDir)%(FileName)%(Extension)</Link>
</None>
</ItemGroup>
Each time you load the project it will automatically link all XAML files found in the Path\To\Your\XAML\ directory. This is the method I use.
Re: Microsoft Blend for Visual Studio and Unity workflow
Faerdan,
Since it was possible in the project file I went to look about writing an extension for this. It turns out the functionality already does (still) exist.
After clicking "Add -> Existing Item..." the "Add" button is actually a dropdown and you can select "Add As Link".
This is available in both Visual Studio and Blend.
Thank you both.
Since it was possible in the project file I went to look about writing an extension for this. It turns out the functionality already does (still) exist.
After clicking "Add -> Existing Item..." the "Add" button is actually a dropdown and you can select "Add As Link".
This is available in both Visual Studio and Blend.
Thank you both.
Re: Microsoft Blend for Visual Studio and Unity workflow
D'oh! If you didn't tell me I'd probably never found out.
If you link a XAML together with a code-behind they don't get stacked as usual when you create a UserControl. You can edit the .csproj to add <DependentUpon>UserControl1.xaml</DependentUpon>, but it's kinda sloppy it doesn't do that automatically. Or maybe I overlooked a feature again.
If you link a XAML together with a code-behind they don't get stacked as usual when you create a UserControl. You can edit the .csproj to add <DependentUpon>UserControl1.xaml</DependentUpon>, but it's kinda sloppy it doesn't do that automatically. Or maybe I overlooked a feature again.
Re: Microsoft Blend for Visual Studio and Unity workflow
Hmm, it did for me. I created the wpf project from Visual Studio and linked to both files (.xaml and .xaml.cs) and they automatically "stacked" and when i open the project in Blend it is the same there. I haven't tried linking inside Blend yet. Which did you try?If you link a XAML together with a code-behind they don't get stacked as usual when you create a UserControl. You can edit the .csproj to add <DependentUpon>UserControl1.xaml</DependentUpon>, but it's kinda sloppy it doesn't do that automatically. Or maybe I overlooked a feature again.
Re: Microsoft Blend for Visual Studio and Unity workflow
Oh I see, you have to add only the .xaml and Blend/VS will include any matching.xaml.cs automatically. I selected both the .xaml and the .xaml.cs in the dialog.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Microsoft Blend for Visual Studio and Unity workflow
First of all, a great thank you to movra for the extensive and precise answer, I think it covers almost all the options available to work with Blend/VS and Unity
In our case, as you can see in the samples we are uploading to the Github, we follow the first option exposed by movra: create a Blend project and the directory structure there (BlendProject/Assets/...). As Blend does not allow you to add existing folders to the project, all the files and directories are always created from Blend. And then you can open the Unity project by selecting the BlendProject directory.
In our case, as you can see in the samples we are uploading to the Github, we follow the first option exposed by movra: create a Blend project and the directory structure there (BlendProject/Assets/...). As Blend does not allow you to add existing folders to the project, all the files and directories are always created from Blend. And then you can open the Unity project by selecting the BlendProject directory.
Who is online
Users browsing this forum: DHSven, Google [Bot] and 22 guests