在使用痣之后,它似乎复选框控件没有ToggleButton,它使用BulleDecorator相反,我不知道这是第一次使用痣..
我想要实现的是,而不是一个复选框,我想要一个红色或绿色的圆圈。
< Style TargetType ={x:Type CheckBox}> < Setter Property =IsHitTestVisibleValue =False/> < Setter Property =FocusableValue =False/> < Setter Property =HorizontalAlignmentValue =Center/> < Setter Property =VerticalAlignmentValue =Top/> < Setter Property =Template> < Setter.Value> < ControlTemplate TargetType ={x:Type ToggleButton}> < Border x:Name =innerBorder> < Ellipse Fill =#FFFF0000Stroke =#FF000000Stretch =Fillx:Name =statusLightWidth =15Height =15Margin =2VerticalAlignment =Center HorizontalAlignment =Center/> < / Border> < ControlTemplate.Triggers> < Trigger Property =IsCheckedValue =True> < Setter TargetName =statusLightProperty =FillValue =#FF00FF00/> < / Trigger> < Trigger Property =IsCheckedValue =False> < Setter TargetName =statusLightProperty =FillValue =#FFFF0000/> < / Trigger> < /ControlTemplate.Triggers> < / ControlTemplate> < /Setter.Value> < / Setter> < / Style>解决方案
看起来你正在寻找DataGridBoundColumn.ElementStyle属性(DataGridCheckBoxColumn派生自DataGridBoundColumn)。如果这对您无效,您可以随时使用DataGridTemplateColumn显示任何您想要的内容。
请参阅 Vincent Sibal的博客,如果你需要更多的信息, / p>
Is there any way to style the checkbox in there? iv tried to define a style for the checkbox but that didn't work.
after using mole it seems like the checkbox control does not have a ToggleButton in it it uses a BulleDecorator instead, im not sure of this first time im using mole..
What i want to achieve is that instead of a check box i want a red or green circle.
<Style TargetType="{x:Type CheckBox}"> <Setter Property="IsHitTestVisible" Value="False"/> <Setter Property="Focusable" Value="False"/> <Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Border x:Name="innerBorder"> <Ellipse Fill="#FFFF0000" Stroke="#FF000000" Stretch="Fill" x:Name="statusLight" Width="15" Height="15" Margin="2" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="statusLight" Property="Fill" Value="#FF00FF00" /> </Trigger> <Trigger Property="IsChecked" Value="False"> <Setter TargetName="statusLight" Property="Fill" Value="#FFFF0000" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>解决方案
It looks like you are looking for DataGridBoundColumn.ElementStyle property (DataGridCheckBoxColumn is derived from DataGridBoundColumn). In case this doesn't work for you, you can always use DataGridTemplateColumn to display anything you want.
Refer to Vincent Sibal's blog if you need more information on this.
更多推荐
WPF DataGridCheckBoxColumn自定义样式?
发布评论