I am developing an application in WPF (mvvm) in which I use LightningChart. Unfortunately, built-in styles do not match the rest of the app. I wanted to use my own styles defined in ResourceDictionary but it is not working.
For example:
Code: Select all
...
xmlns:chart="http://schemas.arction.com/semibindablecharting/ultimate/
...
<SolidColorBrush x:Key="ThemeDarkBackgroundBrush" Color="#46494c" />
<SolidColorBrush x:Key="ThemeLightBackgroundBrush" Color="#4c5c68" />
<chart:Fill x:Key="ViewBackgroundStyle" Color="#4ddcdcdd" GradientFill="Solid" />
<Style TargetType="{x:Type chart:ViewXY}">
<Setter Property="GraphBackground" Value="{DynamicResource ViewBackgroundStyle}"/>
</Style>
<Style TargetType = "{x: Type chart: AxisTitle}">
<Setter Property = "Color" Value = "Red" />
<Setter Property = "Text" Value = "Red" />
</ Style>
<Style TargetType = "{x: Type chart: AxisXTitle}">
<Setter Property = "Color" Value = "Red" />
</ Style>
<Style TargetType = "{x: Type chart: AxisX}">
<Setter Property = "AxisColor" Value = "Red" />
</ Style>
<Style TargetType = "{x: Type ListView}">
<Setter Property = "Background" Value = "{DynamicResource ThemeLightBackgroundBrush}" />
</ Style>
<Style TargetType = "{x: Type GridViewColumnHeader}">
<Setter Property = "Background" Value = "{DynamicResource ThemeDarkBackgroundBrush}" />
</ Style>
My YAxis collection is dynamic (binded to AxisYCollection) and I can not set each axis in XAML separately, but I dont want to set my styles in the View Model class .
Does anyone know if it is possible to use style in XAML without referring directly to objects in code-behind like:
Code: Select all
YAxis.MajorGrid.Color = new Color (35, 255, 255, 255);
Code: Select all
<Lcusb: LightningChartUltimate
Grid.Column = "1">
<Lcusb: LightningChartUltimate.ViewXY>
<Lcusb: ViewXY PointLineSeries = "{Binding LineSeries}"
YAxes = "{Binding LineSeriesYAxes}"
XAxes = "{Binding LineSeriesXAxes}"
LegendBoxes = "{Binding LineSeriesSegmentsLegends}">
<Lcusb: ViewXY.ZoomPanOptions>
<Lcusb: ZoomPanOptions
RightToLeftZoomAction = "RectangleZoomIn"
MouseWheelZooming = "Horizontal"
PanDirection = "Horizontal"
AxisMouseWheelAction = "None"
LeftMouseButtonAction = "Zoom"
RectangleZoomDirection = "Horizontal"
RightMouseButtonAction = "Mr."
ShiftEnabled = "False"
AltEnabled = "False"
CtrlEnabled = "False" />
</lcusb:ViewXY.ZoomPanOptions>
<Lcusb: ViewXY.AxisLayout>
<Lcusb: AxisLayout
YAxesLayout = "Segmented"
SegmentsGap = "30"
Segments = "{Binding LineSeriesSegments}">
</ Lcusb: AxisLayout>
</lcusb:ViewXY.AxisLayout>
</ Lcusb: ViewXY>
</lcusb:LightningChartUltimate.ViewXY>
</ Lcusb: LightningChartUltimate>