WPF DataGridCheckBoxColumn 为什么每次都要点两下才能勾选checkbox ?
1个回答
展开全部
你需要修改一下DataGridTemplateColumn.CellTemplate 就可以了。
<DataGrid AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" HorizontalAlignment="Stretch" Name="dataGrid1" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" >
<DataGrid.Columns>
<!--<DataGridCheckBoxColumn x:Name="dgIscheck" Binding="{Binding IsCheck}" Header="状态" HeaderStringFormat="true" />-->
<DataGridTemplateColumn Header="状态" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="cbStatus" IsChecked="{Binding IsCheck}" Tag="{Binding ID}" Click="cbStatus_Click" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="ID" Width="170" Binding="{Binding ID}" />
<DataGridTextColumn Header="姓名" Width="80" Binding="{Binding UserName}" />
<DataGridTextColumn Header="Email" Width="170" Binding="{Binding MailAddress}" />
</DataGrid.Columns>
</DataGrid>
<DataGrid AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" HorizontalAlignment="Stretch" Name="dataGrid1" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" >
<DataGrid.Columns>
<!--<DataGridCheckBoxColumn x:Name="dgIscheck" Binding="{Binding IsCheck}" Header="状态" HeaderStringFormat="true" />-->
<DataGridTemplateColumn Header="状态" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="cbStatus" IsChecked="{Binding IsCheck}" Tag="{Binding ID}" Click="cbStatus_Click" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="ID" Width="170" Binding="{Binding ID}" />
<DataGridTextColumn Header="姓名" Width="80" Binding="{Binding UserName}" />
<DataGridTextColumn Header="Email" Width="170" Binding="{Binding MailAddress}" />
</DataGrid.Columns>
</DataGrid>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询