stefandv Posted July 16, 2009 Report Share Posted July 16, 2009 If you have a pie chart there is a default marker in the legend (a small pie-part). I want to change this to a rectangle. Setting the Marker.Shape on the series does not work... Could you pls provide me with a sample? Thanks! Quote Link to comment Share on other sites More sharing options...
JuanC Posted July 16, 2009 Report Share Posted July 16, 2009 Unfortunately changing how the marker is represented in the legend requires a new template, your idea of honoring the Marker.Shape is very good but we cannot incorporate it because it would break scenarios where people changed the marker shape in a line chart and then switched to pie. Add this to your Window.Resources or in your app.xaml <DataTemplate x:Key="LegendItemRect"> <Grid x:Name="grid" Margin="{Binding Path=Margin}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" SharedSizeGroup="FirstRow" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Rectangle Fill="{Binding Path=Fill}" Stroke="{Binding Path=Stroke}" Width="12" Height="12" Margin="0,0,4,0" Grid.Column="0" /> <Border Background="Transparent" Grid.Column="1" VerticalAlignment="Center"> <ContentControl IsHitTestVisible="false" Content="{Binding Path=Content}" ContentTemplate="{Binding Path=ContentTemplate}" Foreground="{Binding Path=Foreground}" FontFamily="{Binding Path=FontFamily}" FontSize="{Binding Path=FontSize}" FontStyle="{Binding Path=FontStyle}" FontWeight="{Binding Path=FontWeight}"/> </Border> </Grid> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=Dimmed}"> <DataTrigger.Value> <sys:Boolean>True</sys:Boolean> </DataTrigger.Value> <Setter Property="Opacity" Value="0.25" TargetName="grid" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> And this code to your constructor or loaded handler chart1.LegendBox.ItemAttributes[chart1.AxisX].Template = (DataTemplate) FindResource("LegendItemRect"); Regards, JuanC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.