Blend -> C++ failures - formatting, namespaces
Posted: 04 Oct 2023, 16:24
Hi,
I'm using Blend to create xaml-based UI with a C# mock, after which I copy the xaml files over and write up a C++ equivalent of the mock-ups.
Two areas consistently fail for me and need manual fix-up, meaning any time I copy and forget, I break my C++ version of the UI.
* String formatting - in Blend, if I want for example a time to be always two digits and a trailing 's' for Seconds, it looks like this
(Not doing this _sometimes_ works but sometimes breaks the C# build).
But this breaks in the C++ build, which instead wants what I expected:
* Namespaces - I put my view models in a "ViewModels" folder in the Blend project, which put them inside a namespace, the final result being (with project name as well); "rtg.ViewModels.MyViewModelName", and in xaml that is accessed like so
But this doesn't work in the C++ build - it can't recognize MyViewModelName, or it can't recognize SomeViewHere, and so on. Seems to happen to anything in a namespace like this.
So I try to register on the C++ side my types in the reflection macros - they're inside 'rtg' namespace already, then I try
and outside of namespace
and with ViewModels or viewModels in front
I can't get any combination to work unless I modify the xaml to not use namespaces at all
But this of course breaks in Blend, which seems to encourage namespaces, unless I modify it there and get rid of namespaces that naturally come with the directory structure. Or I maintain two xaml copies, which is not desirable.
What is the canonical and correct way to handle the namespace differences between Blend and Noesis C++? Same Q with the string formatting and why I need to sometimes escape it.
Thanks!
I'm using Blend to create xaml-based UI with a C# mock, after which I copy the xaml files over and write up a C++ equivalent of the mock-ups.
Two areas consistently fail for me and need manual fix-up, meaning any time I copy and forget, I break my C++ version of the UI.
* String formatting - in Blend, if I want for example a time to be always two digits and a trailing 's' for Seconds, it looks like this
Code: Select all
StringFormat=\{0:#\,0.0\}sBut this breaks in the C++ build, which instead wants what I expected:
Code: Select all
StringFormat={}{0:#,0.0}Code: Select all
xmlns:viewModels="clr-namespace:rtg.ViewModels"
...
<UserControl.Resources>
<DataTemplate DataType="{x:Type viewModels:MyViewModelName}">
<views:SomeViewHere/>
</DataTemplate>
</UserControl.Resources>
So I try to register on the C++ side my types in the reflection macros - they're inside 'rtg' namespace already, then I try
Code: Select all
NS_IMPLEMENT_REFLECTION(MyViewModelName, "MyViewModelName")
Code: Select all
NS_IMPLEMENT_REFLECTION(rtg::MyViewModelName, "rtg.MyViewModelName")
Code: Select all
NS_IMPLEMENT_REFLECTION(rtg::MyViewModelName, "rtg.viewModels.MyViewModelName")
NS_IMPLEMENT_REFLECTION(rtg::MyViewModelName, "rtg.viewModels:MyViewModelName")
NS_IMPLEMENT_REFLECTION(rtg::MyViewModelName, "rtg.ViewModels.MyViewModelName")
NS_IMPLEMENT_REFLECTION(rtg::MyViewModelName, "rtg.ViewModels:MyViewModelName")
Code: Select all
<!--xmlns:viewModels="clr-namespace:rtg.ViewModels"-->
...
<UserControl.Resources>
<DataTemplate DataType="{x:Type MyViewModelName}">
<SomeViewHere/>
</DataTemplate>
</UserControl.Resources>
What is the canonical and correct way to handle the namespace differences between Blend and Noesis C++? Same Q with the string formatting and why I need to sometimes escape it.
Thanks!