Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Change the LabelTemplate on an Infragistics XamDoughnutChart
posted

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.

<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:

<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?

Parents
No Data
Reply
  • 34510
    Verified Answer
    Offline posted

    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}.

Children
No Data