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
178
Legend Template using Wrap Panel (Horizontal/Multiple Lines)
posted

I am trying write a template to Legend control. I have version 10.3, .net 4, xamDataChart, with a few line series.

My Legend is Horizontal and I want this to wrap when i have many items(series). Something thing like tab control showing multiple lines. Is this possible? I have to have my Legend at the Top.

I have custom Legend template and Legendtemplateitem, but it's not working. I just comented the ScrowViewer and replace this for a WrapPanel.

Any Help is welcome.

 <ControlTemplate x:Key="xamDataChartLegendTemplate" TargetType ="Charts:Legend">

 

 

 

 

 

<Grid>

 <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="4" Background="{TemplateBinding Background}">

 <Grid Margin="{TemplateBinding Padding }">

 <Grid.RowDefinitions>

 <RowDefinition Height="auto"/>

 <RowDefinition Height="*"/>

 </Grid.RowDefinitions>

 <ContentPresenter Grid.Row="0" Content="{TemplateBinding Content}" />

 

 

 

 

 <!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="auto" VerticalScrollBarVisibility="auto" BorderThickness="0" Background="Transparent">-->

 <WrapPanel Orientation="Horizontal" Grid.Row="1">

 <ContentPresenter Grid.Row="1" x:Name="ContentPresenter" />

 </WrapPanel>

 

 

 

 

 <!--</ScrollViewer>-->

 </Grid >

 </Border>

 <Border IsHitTestVisible="False" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Transparent" CornerRadius="4" Background="{StaticResource GenericOverlay}" />

 </Grid>

 </ControlTemplate>

 

<

 

 

DataTemplate x:Key="xamDataChartCustomLegendItemTemplate">

 

 

 

 

 

 

 

 

 

<StackPanel Orientation="Horizontal" Margin="1" Visibility="{Binding Series

.Visibility}">

 

 

 

 

<ContentPresenter Content="{Binding}" ContentTemplate="{Binding Series

.LegendItemBadgeTemplate}" />

 

 

 

 

<ContentPresenter Content="{Binding Series.Title, TargetNullValue=Series Title

}"/>

 

 

 

 

</StackPanel>

 

 

 

 

 

 

 

 

</DataTemplate>

 

 

Parents Reply Children