你好 首先对不起我的英文。 我最近开始使用wpf的第一个项目。我正在设计一个自定义的DataGrid,它是以编程方式定义的(xaml代码不存在)。 我已经在我的datagrid控件中除了一个复选框,我包裹在里面的所有样式。 问题是,在我的应用程序的其他地方,我定义了一个复选框样式如何正确应用,但我不能应用在我的数据网格中。 其实我的datagrid不会抛出语法错误,但当datagrid运行复选框样式不适用。 样式代码如下所示(它在样式表中定义)Datagrid复选框样式
... <Setter Property="DataGridCheckBoxColumn.ElementStyle">
<Setter.Value>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="Background" Value="Yellow"/>
<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<BulletDecorator Background="Transparent">
<BulletDecorator.Bullet>
<Grid Width="13" Height="13">
<Border x:Name="Border" Background="Pink" BorderBrush="Black" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2"/>
<Path x:Name="CheckMark" Stroke="Green" StrokeThickness="2" SnapsToDevicePixels="False" Data="M1.5000001,1.5833334 L9.7920001,9.6666667 M1.5420001,9.6666667 L9.7083333,1.5000001" Margin="1" ClipToBounds="False" StrokeEndLineCap="Round" StrokeStartLineCap="Round"/>
</Grid>
</BulletDecorator.Bullet>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
</BulletDecorator>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>...
它完全一样的是它`在apliccation应用。 我读了很多关于它,但我不能应用它,我也尝试过,将setter属性设置为“DatagridBoundColum.ElementStyle”,也设置为“CellStyle”,但它不起作用。 任何建议? 非常感谢。