我试图定义一个模板,以便我可以在后面的代码中使用它。
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<Window.Resources>
<DataTemplate x:Key="editColumnTemplate">
<StackPanel Orientation="Horizontal">
<Button x:Name="deleteButton" Content="X" Command="{Binding Path=ClickMeCommand}" HorizontalAlignment="Stretch"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<GridView>
<GridViewColumn Header="Edit" Width="35" CellTemplate="editColumnTemplate"/>
</GridView>
我试图这样做,以便在我的代码背后我能做到:
GridViewColumn newColumn = new GridViewColumn();
newColumn.CellTemplate = editColumnTemplate;
但我在这一行中收到错误:
<GridViewColumn Header="Edit" Width="35" CellTemplate="editColumnTemplate"/>
类型转换器&#34;数据模板&#34;不支持转换 从一个字符串。