BarSeries Template Static resource bug

2 posts, 0 answers
  1. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 27 May 2013 Link to this post

    If I do not use resource work. But why if I use static resource binding for template give me error on Initialization()

    <UserControl.Resources>
           
     

    <

     

     

    conv:NotBoolToVisibilityConverter x:Key="NotBoolToVisibilityConverter" />

     

     

    <conv:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />

     

     

    <SolidColorBrush x:Key="ColorNormal" Color="LimeGreen" />

     

     

    <SolidColorBrush x:Key="ColorLow" Color="Gold" />

     

     

    <SolidColorBrush x:Key="ColorHigh" Color="Red" />

     
            <chartView:ChartSeriesLabelDefinition x:Key="TemplateBarSeriesNormal" >
                <chartView:ChartSeriesLabelDefinition.Template>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding DataItem.CalcValue, Mode=TwoWay}" Foreground="{StaticResource ColorNormal}" Visibility="{Binding DataItem.ShowLabel, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" />
                        </StackPanel>
                    </DataTemplate>
                </chartView:ChartSeriesLabelDefinition.Template>
            </chartView:ChartSeriesLabelDefinition>
     
     
        </UserControl.Resources>
         
         
         <Grid x:Name="LayoutRoot">
          
          
           <chartView:BarSeries ItemsSource="{Binding AlarmGroups, Mode=TwoWay}" ValueBinding="Value" CategoryBinding="NameFormat" CombineMode="Stack" ShowLabels="True" FontFamily="Segoe UI" FontSize="10" BorderThickness="1" BorderBrush="Black"
                                     >
     
                     
                     
                    <chartView:BarSeries.LabelDefinitions>
                        <chartView:ChartSeriesLabelDefinition HorizontalAlignment="Right" VerticalAlignment="Center" Template="{Binding Source={StaticResource TemplateBarSeriesNormal}}">
                             
                            <!-- OLD VERSION DataItem bug is fix
                            <chartView:ChartSeriesLabelDefinition.Template>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding DataItem.CalcValue, Mode=TwoWay}" Foreground="{StaticResource ColorNormal}" Visibility="{Binding DataItem.ShowLabel, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}" />
                                    </StackPanel>
                                </DataTemplate>
                            </chartView:ChartSeriesLabelDefinition.Template>
                            -->
                             
                        </chartView:ChartSeriesLabelDefinition>
                    </chartView:BarSeries.LabelDefinitions>
     
                    <chartView:BarSeries.PointTemplate>
                        <DataTemplate>
                            <Rectangle Fill="{StaticResource ColorNormal}" />
                        </DataTemplate>
                    </chartView:BarSeries.PointTemplate>
                                               
                </chartView:BarSeries>
          
         </Grid>



    See this part of code that is in comment and property

     

    Template="{Binding Source={StaticResource TemplateBarSeriesNormal}}".
     
    <chartView:ChartSeriesLabelDefinition HorizontalAlignment="Right" VerticalAlignment="Center" Template="{Binding Source={StaticResource TemplateBarSeriesNormal}}">

     

     

     

                            
  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 29 May 2013 Link to this post

    Hi,

    This should do the trick:
    <UserControl.Resources>
        <!--...-->
     
        <DataTemplate x:Key="TemplateBarSeriesNormal">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding DataItem.CalcValue, Mode=TwoWay}"
                Foreground="{StaticResource ColorNormal}"
                Visibility="{Binding DataItem.ShowLabel, Mode=TwoWay,
                 Converter={StaticResource BoolToVisibilityConverter}}" />
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
     
    <Grid x:Name="LayoutRoot">
     <chartView:RadCartesianChart >
       <chartView:RadCartesianChart.Series>
          <chartView:BarSeries>
             <chartView:BarSeries.LabelDefinitions>
                <chartView:ChartSeriesLabelDefinition
             HorizontalAlignment="Right"
                 VerticalAlignment="Center"
                 Template="{StaticResource TemplateBarSeriesNormal}">
                </chartView:ChartSeriesLabelDefinition>
             </chartView:BarSeries.LabelDefinitions>
     
    I hope this helps.

    Regards,
    Petar Kirov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top