我有一个控件,在我的例子中是一个 SciChart:SciChartSurface DataSet 绑定到 ChartData,它是我的 viewModel 中的一个对象。
在这个控件中,我需要将 AxisTitle 绑定到我的 viemodel 中的变量。如何访问变量?我试过 AxisTitle="{Binding CharName}" 或 ="{Binding Source={x:Static ViewModels:ViewModelKeys.ChartViewModel}, Path=ChartName}" 但它不起作用。
<UserControl x:Class="UI.WPF.Views.ChartView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:SciChart="http://schemas.abtsoftware.co.uk/scichart"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
xmlns:ViewModels="clr-namespace:UI.ViewModels;assembly=UI.ViewModels"
xmlns:meffed="http:\\www.codeplex.com\MEFedMVVM"
meffed:ViewModelLocator.ViewModel="{x:Static ViewModels:ViewModelKeys.ChartViewModel}">
<Grid>
<SciChart:SciChartSurface x:Name="sciChartSurface" DataSet="{Binding ChartData}">
<SciChart:SciChartSurface.RenderableSeries>
<SciChart:FastLineRenderableSeries SeriesColor="Red"/>
</SciChart:SciChartSurface.RenderableSeries>
<!-- Declare Axes -->
<SciChart:SciChartSurface.YAxis >
<SciChart:NumericAxis AxisTitle="{Binding ???}" AxisAlignment="Left">
<SciChart:NumericAxis.GrowBy>
<SciChart:DoubleRange Min="0.1" Max="0.1"/>
</SciChart:NumericAxis.GrowBy>
</SciChart:NumericAxis>
</SciChart:SciChartSurface.YAxis>
<SciChart:SciChartSurface.XAxis>
<SciChart:DateTimeAxis AxisTitle="Time"
DrawMajorGridLines="True"
DrawMinorGridLines="True"
TextFormatting="HH:mm MMM dd">
<SciChart:DateTimeAxis.GrowBy>
<SciChart:DoubleRange Min="0.1" Max="0.1"/>
</SciChart:DateTimeAxis.GrowBy>
</SciChart:DateTimeAxis>
</SciChart:SciChartSurface.XAxis>
<!-- Declare ChartModifiers -->
<SciChart:SciChartSurface.ChartModifier>
<SciChart:ModifierGroup>
<SciChart:RolloverModifier x:Name="rolloverModifier"
DrawVerticalLine="True"
SourceMode="AllSeries" />
<SciChart:SeriesSelectionModifier />
<SciChart:RubberBandXyZoomModifier IsXAxisOnly="True" IsEnabled="True"/>
<SciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick" />
<SciChart:ZoomPanModifier x:Name="panModifier" IsEnabled="False"/>
<SciChart:XAxisDragModifier/>
<SciChart:YAxisDragModifier/>
</SciChart:ModifierGroup>
</SciChart:SciChartSurface.ChartModifier>
</SciChart:SciChartSurface>
</Grid>