KeldorKatarn
Topic Author
Posts: 160
Joined: 30 May 2014, 10:26

Implicit DataTemplates

07 Apr 2021, 23:57

I just tried to add DataTemplates for Views in a ResourceDIctionary like this:
<DataTemplate DataType="{x:Type vm:MyViewModel}">
	<v:MyView />
</DataTemplate
In WPF that works fine, yet Unity Noesis complains that I cannot add a DataTemplate to a ResourceDictionary without specifying a key.
This is an issue. Implicitly used DataTemplates are supposed to be used this way. Why do I need to specifiy a key? This is another inconsistency between WPF and Noesis
that gets in the way of the Blend + Noesis workflow.

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

Re: Implicit DataTemplates

09 Apr 2021, 13:10

I just created a view model like this:
namespace Testing
{
    public class MyViewModel { }
}
And use it in a xaml like this:
<Grid
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Testing">
    <Grid.Resources>
      <DataTemplate DataType="{x:Type local:MyViewModel}">
        <Rectangle Fill="Red"/>
      </DataTemplate>
    </Grid.Resources>
    <ContentControl Content="{Binding}"/>
</Grid>
And it parses fine and works as expected when I set an instance of MyViewModel in the DataContext.

What version of NoesisGUI are you using? My tests are with latest 3.0.11 version.
 
KeldorKatarn
Topic Author
Posts: 160
Joined: 30 May 2014, 10:26

Re: Implicit DataTemplates

10 Apr 2021, 17:56

I couldn't reproduce this for some reason. I'll report back if I run into it again. You can close this for now.
 
User avatar
jsantos
Site Admin
Posts: 3095
Joined: 20 Jan 2012, 17:18
Contact:

Re: Implicit DataTemplates

12 Apr 2021, 11:17

Please, open a bug report if you hit this again. Thanks

Who is online

Users browsing this forum: No registered users and 1 guest