Ok, this is what I have so far:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:s="clr-namespace:System;assembly=mscorlib"
Title="MainWindow"
Height="350"
Width="525">
<Window.Resources>
<DataTemplate x:Key="CheckboxColumn"
DataType="{x:Type sys:Boolean}">
<CheckBox IsChecked="{Binding Path=.}" />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.Resources>
<x:Array Type="{x:Type s:Boolean}"
x:Key="items">
<s:Boolean>False</s:Boolean>
<s:Boolean>True</s:Boolean>
</x:Array>
</G开发者_开发问答rid.Resources>
<ListView ItemsSource="{StaticResource items}">
<ListView.View>
<GridView>
<GridViewColumn Header="Number"
DisplayMemberBinding="{Binding Path=.}"
CellTemplate="{StaticResource CheckboxColumn}" />
<GridViewColumn Header="Name"
DisplayMemberBinding="{Binding Path=.}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
Even though I set the CellTemplate
I still just get plain text.
Since you didn't post your data class that you are binding to, I can't tell for certain, but it appears that you may be binding to a non-Boolean type, and the binding is failing. Have you watched the Output window for binding exceptions?
Duh. You can't have a DisplayMemberBinding
and a CellTemplate
for the same column.
精彩评论