数据绑定到文本块
本文关键字:文本 数据绑定 | 更新日期: 2023-09-27 18:19:38
this.PieSeries = new ObservableCollection<RevenueProperties>()
{
new RevenueProperties() { Items = "iTunes", Revenue = 6},
new RevenueProperties() { Items = "Others", Revenue = 4},
new RevenueProperties() { Items = "iPhone", Revenue = 48},
new RevenueProperties() { Items = "iPad", Revenue = 21},
new RevenueProperties() { Items = "Mac", Revenue = 18},
new RevenueProperties() { Items = "iPod", Revenue = 2},
};
this.DataContext = this;
<Window.Resources>
<DataTemplate x:Key="labelTemplate">
<Grid>
<TextBlock Text="{Binding Items}"/>
<TextBlock Text="{Binding Revenue}"/>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Chart:PieSeries ExplodeIndex="0" ExplodeRadius="15" ExplodeAll="False" Palette="Custom" LabelPosition="Inside"
ItemsSource="{Binding PieSeries}" XBindingPath="Items" YBindingPath="Revenue">
<Chart:PieSeries.AdornmentsInfo>
<Chart:ChartAdornmentInfo FontSize="9" ShowLabel="True" SegmentLabelContent="Percentage"
ShowConnectorLine="True" LabelTemplate="{StaticResource labelTemplate}"/>
</Syncfusion:PieSeries.AdornmentsInfo>
</Chart:PieSeries>
我尝试上面的程序文本块值不绑定任何东西,当我运行这个程序时得到空饼图。请帮助解决此绑定问题
您是否在类后面的窗口代码上实现了 INotiFyProperty 接口?如果没有,请实现通知...,然后从 PieSeries、Items 和 Revenue 字段的 setter 调用 OnPropertyChanged 方法。
查看以下链接,了解INotify的详细说明...接口:http://www.codeproject.com/Articles/41817/Implementing-INotifyPropertyChanged