Shaun Luttin
Shaun Luttin

Reputation: 141452

'DataTemplate' type does not have a public TypeConverter class

I have created the following DataTemplate for a GridViewColumn.

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!--'DataTemplate' type does not have a public TypeConverter class.-->
    <DataTemplate x:Key="myCellTemplate">        
        <TextBlock Text="{Binding}" ToolTip="{Binding}" Background="Red" />
      </DataTemplate>

</ResourceDictionary>

I use the DataTemplate here:

    <ListView 
      ItemsSource="{Binding AllOrders}">
        <ListView.View>
            <GridView>
                <GridViewColumn 
                    DisplayMemberBinding="{Binding Id}"
                    CellTemplate="myCellTemplate" />
            </GridView>
        </ListView.View>
    </ListView>

I am receiving the following error:

'DataTemplate' type does not have a public TypeConverter class.

How do I fix it?

Upvotes: 0

Views: 185

Answers (1)

Shaun Luttin
Shaun Luttin

Reputation: 141452

Replace myCellTemplate with {StaticResource myCellTemplate} as follows:

 <GridViewColumn 
      DisplayMemberBinding="{Binding Id}"
      CellTemplate="{StaticResource myCellTemplate}" />

Upvotes: 1

Related Questions