This is a migrated thread and some comments may be shown as answers.

Legend is not aligned correctly

2 Answers 88 Views
Chart
This is a migrated thread and some comments may be shown as answers.
ardmore
Top achievements
Rank 1
ardmore asked on 13 Nov 2017, 08:40 PM

I use RadLegend control for my RadChart. Here is my xaml code. However it is not aligning correctly. See the attached image.

<telerik:RadLegend.ItemTemplate>
  <DataTemplate>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Path Width="15" Height="15" Fill="{Binding MarkerFill}"
                      HorizontalAlignment="Left" Grid.Column="0">
           <Path.Data>
                        <Binding Path="ActualMarkerGeometry"
                             RelativeSource="{RelativeSource AncestorType=telerik:LegendItemControl}">
                        </Binding>
                      </Path.Data>
            </Path>
             <TextBlock Text="{Binding Title}" Foreground="White" Margin="15 0 0 0" HorizontalAlignment="Left" Grid.Column="1" />
             </Grid>
           </DataTemplate>
   </telerik:RadLegend.ItemTemplate>

2 Answers, 1 is accepted

Sort by
0
Sia
Telerik team
answered on 14 Nov 2017, 11:51 AM
Hello,

The layout depends on the grid and its columns. Thats is why I would suggest
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition />
</Grid.ColumnDefinitions>

However I am not sure what could cause the TextBlocks' right alignment. That is why I would appreciate a sample project showing the settings of your project.

Regards,
Sia
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
ardmore
Top achievements
Rank 1
answered on 14 Nov 2017, 01:07 PM

For some reason I can't upload a sample project, but I find the issue. You have to define the width of the column a fixed value.

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="50" />
    <ColumnDefinition  Width="100"/>
</Grid.ColumnDefinitions>

Using Auto is not working. Maybe it is a bug of RadLegend control.

 

Tags
Chart
Asked by
ardmore
Top achievements
Rank 1
Answers by
Sia
Telerik team
ardmore
Top achievements
Rank 1
Share this question
or