DataTemplate with DataType sys:Single or sys:String is not used.
Posted: 04 Sep 2018, 02:04
I have a ListBox with different items, when the item is a string or float I want to use a specific DataTemplate. Using DataType="{x:Type sys:String}" where xmlns:sys="clr-namespace:System;assembly=mscorlib" works when I run in windows but not under NoesisGUI. I have another template for when the item is a vector DataType="{x:Type local:UiVector3}" and this type works correctly and my DataTemplate for it is used.
Here is my xaml code, the NsPropertyTemplate is usesd because I set it as ItemTemplate="{DynamicResource NsPropertyTemplate}" The UiVector3 is correctly identified and that template is used but for a string I get the standard output and my template is not used.
Side note:
I can't get UnityEngine:Vector3 to work at all, get an internal error. I have a workaround for this where I simply change them to a locally defined UiVector3 in the code behind setter.
Here is my xaml code, the NsPropertyTemplate is usesd because I set it as ItemTemplate="{DynamicResource NsPropertyTemplate}" The UiVector3 is correctly identified and that template is used but for a string I get the standard output and my template is not used.
Code: Select all
<DataTemplate DataType="{x:Type sys:String}">
<StackPanel Orientation="Vertical">
<TextBox Text="{Binding Path=Content, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</StackPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type local:UiVector3}">
<StackPanel Orientation="Horizontal">
<TextBox Width="64" Text="{Binding x, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Width="64" Text="{Binding y, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox Width="64" Text="{Binding z, UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="NsPropertyTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name}"/>
<ContentPresenter Content="{Binding Path=Value, Mode=TwoWay}"/>
</StackPanel>
</DataTemplate>
I can't get UnityEngine:Vector3 to work at all, get an internal error. I have a workaround for this where I simply change them to a locally defined UiVector3 in the code behind setter.