作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最佳答案
下面是一些创建 DataPointStyle
的示例 XAML。我还创建了一些其他样式,以便结果看起来一致:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication216"
xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:Primitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
x:Class="WpfApplication216.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<PointCollection x:Key="PCol1">1,10 2,30 3,20 4,40</PointCollection>
<PointCollection x:Key="PCol2">1,40 2,20 3,30 4,10</PointCollection>
<Style x:Key="DataPointStyle1" TargetType="{x:Type chartingToolkit:LineDataPoint}">
<Setter Property="Background" Value="LightBlue"/>
<Setter Property="Width" Value="32"></Setter>
<Setter Property="Height" Value="32"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Ellipse Fill="LightBlue" Stroke="DarkBlue" StrokeThickness="3"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DataPointStyle2" TargetType="{x:Type chartingToolkit:LineDataPoint}">
<Setter Property="Background" Value="LightGreen"/>
<Setter Property="Width" Value="16"></Setter>
<Setter Property="Height" Value="16"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Rectangle Fill="LightGreen" Stroke="DarkGreen" StrokeThickness="3"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PolylineStyle1" TargetType="{x:Type Polyline}">
<Setter Property="StrokeThickness" Value="1"/>
<Setter Property="Stroke" Value="Blue"></Setter>
</Style>
<Style x:Key="PolylineStyle2" TargetType="{x:Type Polyline}">
<Setter Property="StrokeThickness" Value="2"/>
<Setter Property="Stroke" Value="Green"></Setter>
</Style>
<Style x:Key="LineSeriesStyle1" TargetType="{x:Type chartingToolkit:LineSeries}" >
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type chartingToolkit:LineSeries}">
<Canvas x:Name="PlotArea">
<Polyline Points="{TemplateBinding Points}" Style="{DynamicResource PolylineStyle1}" />
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LineSeriesStyle2" TargetType="{x:Type chartingToolkit:LineSeries}" >
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type chartingToolkit:LineSeries}">
<Canvas x:Name="PlotArea">
<Polyline Points="{TemplateBinding Points}" Style="{DynamicResource PolylineStyle2}" />
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<chartingToolkit:Chart Margin="0">
<chartingToolkit:LineSeries DataPointStyle="{StaticResource DataPointStyle1}" Style="{StaticResource LineSeriesStyle1}" DependentValuePath="Y" IndependentValuePath="X" ItemsSource="{StaticResource PCol1}"/>
<chartingToolkit:LineSeries DataPointStyle="{StaticResource DataPointStyle2}" Style="{StaticResource LineSeriesStyle2}" DependentValuePath="Y" IndependentValuePath="X" ItemsSource="{StaticResource PCol2}"/>
</chartingToolkit:Chart>
</Grid>
关于c# - 如何将 WPFToolkit 中的 DataPointStyle 从圆形更改为方形、三角形...等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36823865/
我想覆盖 DataPointStyle的LineSeries在我的 WPF 工具包中 Chart :
我正在生成一些动态 vizframe 柱形图,方法是循环处理从我的 Odata 服务获得的响应。我对图表的要求之一是根据数据中的字段值以不同颜色显示列。我们称之为验证状态。 我非常清楚如何在正常情况下
我有 WPFToolkit 图表,它有几个线条: 如何将 lineserias DataPointStyle 从圆形更改为方形、三角形...等? 最佳答案 下面是一些创建 DataPointStyle
我是一名优秀的程序员,十分优秀!