数据绑定到 TextBlock
Data Binding to TextBlock
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>
我尝试上面的程序文本块值不绑定任何东西,当我运行这个程序得到空饼图时。请帮忙解决这个绑定问题
您是否在 class 后面的 window 代码中实现了 INotiFyProperty 接口?
如果没有,请在您的 window 上实施 Inotify... 并从 PieSeries、Items 和 Revenue 字段的 setter 调用 OnPropertyChanged 方法。
查看下面link关于 INotify... 接口的详细解释:
http://www.codeproject.com/Articles/41817/Implementing-INotifyPropertyChanged
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>
我尝试上面的程序文本块值不绑定任何东西,当我运行这个程序得到空饼图时。请帮忙解决这个绑定问题
您是否在 class 后面的 window 代码中实现了 INotiFyProperty 接口? 如果没有,请在您的 window 上实施 Inotify... 并从 PieSeries、Items 和 Revenue 字段的 setter 调用 OnPropertyChanged 方法。
查看下面link关于 INotify... 接口的详细解释: http://www.codeproject.com/Articles/41817/Implementing-INotifyPropertyChanged