@@ -100,18 +100,32 @@ The small segments in the pie chart can be grouped into the “others” categor
100100
101101{% highlight xaml %}
102102
103- <chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="Country" YBindingPath="Count"
104- GroupMode="Value" GroupTo="1000" >
105-
106- <chart:PieSeries.AdornmentsInfo>
107- <chart:ChartAdornmentInfo ShowConnectorLine="True"
108- ConnectorHeight="80"
109- ShowLabel="True"
110- LabelTemplate="{StaticResource DataLabelTemplate}"
111- SegmentLabelContent="LabelContentPath">
112- </chart:ChartAdornmentInfo>
113- </chart:PieSeries.AdornmentsInfo>
114- </chart:PieSeries>
103+ <Window.Resources>
104+ <local:DataLabelTemplateConverter x:Key="DataLabelConverter"/>
105+ <local:SegmentBrushConverter x:Key="BackgroundConverter"/>
106+
107+ <DataTemplate x:Key="DataLabelTemplate">
108+ <StackPanel Orientation="Vertical" Margin="5">
109+ <TextBlock Text="{Binding Converter={StaticResource DataLabelConverter}}"
110+ Margin="3" Foreground="White">
111+ </TextBlock>
112+ </StackPanel>
113+ </DataTemplate>
114+ </Window.Resources>
115+
116+ <chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="Country" YBindingPath="Count"
117+ GroupMode="Value" GroupTo="1000" >
118+
119+ <chart:PieSeries.AdornmentsInfo>
120+ <chart:ChartAdornmentInfo ShowConnectorLine="True"
121+ ConnectorHeight="80"
122+ ShowLabel="True"
123+ LabelPosition="OutsideExtended"
124+ LabelTemplate="{StaticResource DataLabelTemplate}"
125+ SegmentLabelContent="LabelContentPath">
126+ </chart:ChartAdornmentInfo>
127+ </chart:PieSeries.AdornmentsInfo>
128+ </chart:PieSeries>
115129
116130{% endhighlight %}
117131
@@ -131,6 +145,32 @@ The small segments in the pie chart can be grouped into the “others” categor
131145
132146 pieSeries.AdornmentsInfo = adornmentInfo;
133147
148+
149+ public class DataLabelTemplateConverter : IValueConverter
150+ {
151+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
152+ {
153+ if (value is ChartPieAdornment adornment)
154+ {
155+ if (adornment.Item is CountryInfo model)
156+ {
157+ // Case 1: Single data label item
158+ }
159+ else if (adornment.Item is IEnumerable<object> group)
160+ {
161+ // Case 2: Grouped items (e.g., List<CountryInfo>)
162+ }
163+ }
164+
165+ return value;
166+ }
167+
168+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
169+ {
170+ throw new NotImplementedException();
171+ }
172+ }
173+
134174{% endhighlight %}
135175
136176{% endtabs %}
0 commit comments