【发布时间】:2015-10-05 18:41:03
【问题描述】:
我正在使用 Winrt Xaml 工具包进行自定义 PieChart,但我很难绑定到我的主要元素的属性。代码如下:
<Charting:Chart x:Name="PieChart" Title="Pie Title" Width="300" Height="300">
<Charting:Chart.Series>
<Charting:PieSeries Title="Population" IndependentValueBinding="{Binding Name}" DependentValueBinding="{Binding Amount}" IsSelectionEnabled="False" Width="125" Height="125" />
</Charting:Chart.Series>
<Charting:Chart.LegendStyle>
<Style TargetType="datavis:Legend">
<Setter Property="ItemContainerStyle" xmlns:series="using:WinRTXamlToolkit.Controls.DataVisualization.Charting">
<Setter.Value>
<Style TargetType="series:LegendItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="series:LegendItem">
<StackPanel Orientation="Horizontal">
<datavis:Title Content="{TemplateBinding Content}" />
<TextBlock Text="{Binding Amount}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</Charting:Chart.LegendStyle>
</Charting:Chart>
在我的LegendItem 中,我有一个TextBlock,我想将Charting:PieSeries 元素中的DependentValueBinding 属性绑定到它。我怎样才能做到这一点?我也尝试引用元素Self,但无法获取子属性。
【问题讨论】:
标签: c# xaml windows-runtime winrt-xaml-toolkit