HierarchicalDataTemplate not finding correct public Type

For some reason I can't get my Grid to find my DataType in the datatemplate. I confirmed the assembly was present and accessible via code-behind, but XAML refuses to recognize it, I also tried slapping the Assembly attribute onto the Mapping tag but to no avail. The DataContract type is Franchise in the Log.DataContracts namespace.

< Mapping XmlNamespace="Log" ClrNamespace="Log.DataContracts" >
<
Grid x:Class="Client.WPFControls.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Log="Log">
<
Grid>
<
Grid.Resources>
<
HierarchicalDataTemplate x:Key="FranchiseTemplate" DataType="{x:Type Log:Franchise}"
ItemsSource="{Binding Path=Elements}">
<
StackPanel Orientation="Horizontal">
<
TextBlock Text="{Binding Path=ElementId}" Margin="0 1.5 0 0" />
</
StackPanel>
</
HierarchicalDataTemplate>
</
Grid.Resources>
<
TreeView ItemsSource="{Binding Path=Elements}"
ItemTemplate="{StaticResource FranchiseTemplate}" />
</
Grid>
</
Grid>



Answer this question

HierarchicalDataTemplate not finding correct public Type

  • joan10

    That almost did the trick, I also needed the assembly part:

    xmlns:myNS="clr-namespace:Log.DataContracts;assembly=MyDLLAssembly"


  • voy

    Feb CTP has a breaking change on mapping.

    OLD

    < Mapping XmlNamespace="local" ClrNamespace="MyCompany.MyProduct" >
    <… xmlns:my="local" >

    NEW

    <… xmlns:my="clr-namespace:MyCompany.MyProduct" >



  • HierarchicalDataTemplate not finding correct public Type