0
我试图用WPF绘制一些分散图表,并努力绘制通常出现在图表轴上的小刻度标记。我的视图模型使用每个轴的List<Tick>
来定义刻度的位置,其中每个Tick
项只是刻度落在轴上的笛卡尔坐标。我有一个IMultiValueConverter
,它使用画布大小将单个点转换为可以呈现的Line对象...但是如何将其绑定? WPF希望我指定X1,X2,Y1和Y2,但我只想给它一行。WPF - 使用返回一行的转换器绑定一行
我的想法是定义如下的数据模板,但它不能编译,因为我不能直接给Line
多重绑定。是否有我可以使用的中间元素/属性?
<DataTemplate DataType="{x:Type viewModel:Tick}" x:Key="TickTemplate">
<Line>
<WhatsMissing?>
<MultiBinding Converter="{StaticResource PointsConverter}">
<Binding Path="Points"/>
<Binding Path="DataContext.MinPoint" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}"/>
<Binding Path="DataContext.MaxPoint" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}"/>
<Binding Path="ActualWidth" ElementName="ChartCanvas"/>
<Binding Path="ActualHeight" ElementName="ChartCanvas"/>
</MultiBinding>
</WhatsMissing?>
</Line>
</DataTemplate>