HateDread
Topic Author
Posts: 74
Joined: 06 Feb 2020, 10:27

C++ ViewModel Clarification

31 May 2024, 06:00

Hey ya'll,

First of all, my first impressions are super positive; this tool looks great, and I'm really keen to get into it! Also the samples are slick - the Engineering sample is perfect for parts of my current project.

I just wanted to clarify the intended/future workflow for C++-based stacks with Noesis + Studio. Obviously there's no SDK access in this release, and I totally get that as it's in Alpha. For now, I presume we should just mock up the ViewModels we have using the in-app UI-driven control and/or hand-editing XML files? And in future, will those XML files be generated via the API somehow? Just wondering how far to go with hand-mocking everything right now if that approach will be superseded in the near future.

Congrats on the release!
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ ViewModel Clarification

31 May 2024, 18:40

Thank you for the kind words!

We have two different workflows in mind for Design-Time ViewModels in Studio:

1. Programmer-Created ViewModel: In this workflow, the programmer creates a C++ ViewModel, which is then exposed via reflection to Studio for use at design time. The main disadvantages of this approach are that it requires extending Noesis Studio (it won’t work with the vanilla version or the current alpha), and designers must wait for programmers to create the ViewModel, leading to inefficiencies in the workflow. This workflow will be supported and we don't plan to deprecate it.

2. Designer-Created ViewModel: In the second workflow, designers create the design-time ViewModels. When these ViewModels are needed at runtime, they are recreated in C++. This recreation can be done manually or by using a script that parses the XML stored in the .noesis folder and generates native code. We could also expose an extensible API to invoke the conversion of the ViewModel using a contextual menu in Studio, and why not, provide defaults converters for C++ and C# at least.
 
a.lashkevich
Posts: 21
Joined: 23 Sep 2024, 08:50

Re: C++ ViewModel Clarification

25 Sep 2024, 14:00

Hi jsantos,
Could you please clarify a bit about the second workflow? Do you have a view model converter from XAML to C++, or is your team only planning to implement it? Could you share any details or timelines regarding when it might be available for use?
Thanks
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ ViewModel Clarification

27 Sep 2024, 10:17

Created view models are available in .noesis/data/structures. You can easily parse each file and convert them to C++:
<Class Name="ProjectInfo">
  <Property Name="Name" Type="String" StringMinWordCount="0" StringMaxWordCount="10"/>
  <Property Name="Path" Type="String" StringMinWordCount="0" StringMaxWordCount="10"/>
  <Property Name="IsNew" Type="Boolean"/>
</Class>
We are still determining how to expose a callback in Studio to invoke custom scripts for this process. However, this is currently a low-priority task.
 
a.lashkevich
Posts: 21
Joined: 23 Sep 2024, 08:50

Re: C++ ViewModel Clarification

27 Sep 2024, 11:47

thanks for anwer, sorry, I'm new in xaml, could you please describe how to convert xaml view models to C++ ? I didn't find example in samples folder
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ ViewModel Clarification

28 Sep 2024, 11:47

For the ViewModel mentioned above, you can generate the following code:
class ProjectInfo: public BaseComponent
{
public:
    String _name;
    String _path;
    bool _isNew;

private:
    NS_IMPLEMENT_INLINE_REFLECTION(ProjectInfo, BaseComponent)
    {
        NsProp("Name", &ProjectInfo::_name);
        NsProp("Path", &ProjectInfo::_path);
        NsProp("IsNew", &ProjectInfo::_isNew);
    }
};
You can find more information about C++ reflection in the Reflection section of the C++ Architecture Guide.

The Data Binding sample included in the SDK is also a great resource for learning about binding view models.

Who is online

Users browsing this forum: No registered users and 1 guest