Legend is not aligned correctly

3 posts, 0 answers
  1. ardmore
    ardmore avatar
    24 posts
    Member since:
    Jul 2016

    Posted 13 Nov Link to this post

    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. Sia
    Admin
    Sia avatar
    694 posts

    Posted 14 Nov Link to this post

    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.
  3. ardmore
    ardmore avatar
    24 posts
    Member since:
    Jul 2016

    Posted 14 Nov in reply to Sia Link to this post

    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.

     

Back to Top