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}}"
>