User avatar
sfernandez
Site Admin
Posts: 2056
Joined: 22 Dec 2011, 19:20

Re: Microsoft Blend for Visual Studio and Unity workflow

10 Nov 2020, 17:42

One thing to pay attention to, though, is that the partial class in Unity (with the Noesis definitions) won't have access to the automatically generated elements, so you'll need to extract them yourself.
One way we recommend to do that is by having inside the code-behind code for NOESIS all the x:Named elements that you are going to use cached after the LoadComponent call:
public class MainView : UserControl
{
  public MainView()
  {
    InitializeComponent();
    this.AcceptButton.Click += this.OnAccept;
  }
  
#if NOESIS
  Button AcceptButton;
  private void InitializeComponent()
  {
    Noesis.GUI.LoadComponent(this, "Assets/UI/MainView.xaml");
    this.AcceptButton = (Button)FindName("AcceptButton");
  }
#endif

  private void OnAccept(object sender, RoutedEventArgs e)
  {
  }
}
This way you can share most of the C# code that works in Blend.

Tags:
 
User avatar
jsantos
Site Admin
Posts: 3015
Joined: 20 Jan 2012, 17:18
Contact:

Re: Microsoft Blend for Visual Studio and Unity workflow

10 Nov 2020, 19:28

Or using the generator available at

viewtopic.php?f=3&t=1930

We had plans to officially incorporate them into v3.0, but we didn't have enough time for that. It is coming in 3.1 "probably".
 
Rocko Bonaparte
Posts: 18
Joined: 13 Oct 2020, 08:32

Re: Microsoft Blend for Visual Studio and Unity workflow

22 Feb 2021, 16:59

I'm trying to retrofit Movra's "Option C" to my project now that I've gotten comfortable:
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 I try to start a build of the application using Blend instead of Unity, it can't find paths for my resources. I'm assuming it's searching within its own project hierarchy. I symbolically linked in the files from Unity, which Blend then uses to produce output in its (in this case, BlendMyUnityProject) obj/Debug path. The directory structure is not preserved. So when I need to find something like "../MyResources.xaml" it's looking in the wrong place and can't resolve it.

Something more specific: My literal file hierarchy has:

/MainMenuResources.xaml
/Setup/SetupUserControl.xaml (this has a resource dictionary that sources ../MainMenuResources.xaml)

In the editor and also when I run, it can't find ../MainMenuResources.xaml. If I look in the build output, I see a flat file hierarchy:
/MainMenuResources.xaml
/SetupUserControl.xaml (../MainMenuResources.xaml would look in the wrong place)

When I had a separate Visual Studio project, the obj folder would preserve the file folders. I suspect there's something I need to do with the symlinks. I hope I don't have to create parallel folders in my Blend project (even if I can symlink the actual files) but it occurred to me as a workaround.
 
User avatar
jsantos
Site Admin
Posts: 3015
Joined: 20 Jan 2012, 17:18
Contact:

Re: Microsoft Blend for Visual Studio and Unity workflow

24 Feb 2021, 21:41

We no longer recommend using links because the way they work is different (broken?) in different versions of Blend. Everything is easier when your Blend project is located on top of Assets folder.

Who is online

Users browsing this forum: No registered users and 4 guests