I have an Infragistics WPF XamDoughnutChart which displays data binded from an ObservableCollection called Data and shows Data.Value and Data.Label on its chart labels.
XamDoughnutChart
ObservableCollection
Data
Data.Value
Data.Label
<Grid> <ig:XamDoughnutChart x:Name="MyDonut" CenterData="{Binding TotalItemCount}"> <ig:XamDoughnutChart.Series> <ig:RingSeries ItemsSource="{Binding Data}" ValueMemberPath="Value" LabelMemberPath="Label"> </ig:RingSeries> </ig:XamDoughnutChart.Series> </ig:XamDoughnutChart> </Grid>
I am trying to change the LabelTemplate but nothing I try works:
LabelTemplate but nothing I try works:
<Window.Resources> <DataTemplate x:Key="MyLabelTemplate"> <Label Foreground="Blue" Content="test"/> <-- **This shows 'test' in blue <Label Foreground="Blue" Content="{Binding}"/> <-- Does nothing <Label Foreground="Blue" Content="{Binding Path=Label}"/> <-- Does nothing <Label Foreground="Blue" Content="{Binding Path=Value}"/> <-- Does nothing </DataTemplate> </Window.Resources> <Grid> <ig:XamDoughnutChart x:Name="MyDonut" CenterData="{Binding TotalCount}"> <ig:XamDoughnutChart.Series> <ig:RingSeries ItemsSource="{Binding Data}" ValueMemberPath="Value" LabelMemberPath="Label" LabelTemplate="{StaticResource MyLabelTemplate}"> <-- **Add a LabelTemplate** </ig:RingSeries> </ig:XamDoughnutChart.Series> </ig:XamDoughnutChart> </Grid>
How can I actually change this labels template?
Hi Jimmy,
The DataContext for your template is an Infragistics object which exposes an Item property you can use to get your datasource item. So your binding should look like this: {Binding Path=Item.Label}.