Hy Telerik,
is it possible to set the ElementStyle from an CustomGridLine with an new style in Code behind.
I wana do something like this in code behind:
I try it with that code:
I know that the style works, because of the "VisibilityProperty".
I can set the VisibilityProperty to Visible and the CustomGridLine is visible.
And i can set it to Collapsed and the CustomGridLine is hidden.
Can you help me please!
is it possible to set the ElementStyle from an CustomGridLine with an new style in Code behind.
I wana do something like this in code behind:
<
Style
x:Key
=
"CustomGridLineCursorX3"
TargetType
=
"Line"
>
<
Setter
Property
=
"StrokeDashArray"
Value
=
"1"
/>
</
Style
>
this
.GridLineCursorX7test =
new
CustomGridLine()
{
Stroke =
new
SolidColorBrush(Colors.Blue),
StrokeThickness = 2,
ElementStyle =
this
.Resources[
"CustomGridLineCursorX3"
]
as
Style
XIntercept = 2500
};
I try it with that code:
DoubleCollection dc =
new
DoubleCollection();
dc.Add(1.2);
Style style2 =
new
Style(
typeof
(System.Windows.Shapes.Line));
style2.Setters.Add(
new
Setter(System.Windows.Shapes.Line.VisibilityProperty, System.Windows.Visibility.Collapsed));
style2.Setters.Add(
new
Setter(System.Windows.Shapes.Line.StrokeDashArrayProperty, dc));
this
.GridLineCursorX7test =
new
CustomGridLine()
{
Stroke =
new
SolidColorBrush(Colors.Blue),
StrokeThickness = 2,
ElementStyle = style2,
XIntercept = 2500
};
xChartArea.Annotations.Add(
this
.GridLineCursorX7test);
I know that the style works, because of the "VisibilityProperty".
I can set the VisibilityProperty to Visible and the CustomGridLine is visible.
And i can set it to Collapsed and the CustomGridLine is hidden.
Can you help me please!