WPF 图表图例项目样式
我正在尝试在 WPF 图表中设置图例项目的样式。我有以下 LegendStyle,但这不会改变任何内容。我做错了什么?
谢谢!
<Style x:Key="LegendStyle1" TargetType="{x:Type datavis:Legend}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="charting:LegendItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:LegendItem">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Rectangle Width="40" Height="40" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" VerticalAlignment="Center" />
<datavis:Title Content="{TemplateBinding Content}" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
I am trying to style the Legend Items in my WPF Chart. I have the following LegendStyle, but this doesn't change anything. What am I doing wrong?
Thanks!
<Style x:Key="LegendStyle1" TargetType="{x:Type datavis:Legend}">
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="charting:LegendItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="charting:LegendItem">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Rectangle Width="40" Height="40" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" VerticalAlignment="Center" />
<datavis:Title Content="{TemplateBinding Content}" VerticalAlignment="Center"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想也许
TargetType="charting:Legend">
I think maybe
TargetType="charting:Legend">