1

我正在使用 Telerik Linear Guage 来显示加速度计。我分别有 X、Y、Z 坐标的三个仪表。

问题在于值绑定。我使用以下代码绑定值,但它不起作用,

    //CodeBehind
    public string XCord { get; set; }

    public string YCord { get; set; }

    public string ZCord { get; set; }

            // Constructor
    public MainPage()
    {
        InitializeComponent();
        acc = new Accelerometer();
        acc.CurrentValueChanged += acc_CurrentValueChanged;
        acc.Start();
    }

    void acc_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
    {
        XCord = Math.Abs(acc.CurrentValue.Acceleration.X).ToString();
        YCord = Math.Abs(acc.CurrentValue.Acceleration.Y).ToString();
        ZCord = Math.Abs(acc.CurrentValue.Acceleration.Z).ToString();
    }


      <!--XAML CODE-->
     <gauges:MarkerGaugeIndicator Value="57.67"
                                             gauges:LinearGaugeRange.IndicatorOffset="40"
                                             x:Name="indicator5"
                                             IsAnimated="True"
                                             IsMarkerRotated="False">
            <gauges:MarkerGaugeIndicator.MarkerTemplate>
                <DataTemplate>
                    <Grid Width="37"
                                  Height="37">
                        <TextBlock x:Name="txt1" Text="{Binding XCord}"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Center"
                                           FontSize="13"
                                           FontWeight="Bold"/>
                    </Grid>
                </DataTemplate>
            </gauges:MarkerGaugeIndicator.MarkerTemplate>
        </gauges:MarkerGaugeIndicator>

         <gauges:MarkerGaugeIndicator Value="57.67"
                                             gauges:LinearGaugeRange.IndicatorOffset="40"
                                             x:Name="indicator6"
                                             IsAnimated="True"
                                             IsMarkerRotated="False">
            <gauges:MarkerGaugeIndicator.MarkerTemplate>
                <DataTemplate>
                    <Grid Width="37"
                                  Height="37">
                        <TextBlock x:Name="txt2" Text="{Binding YCord}"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Center"
                                           FontSize="13"
                                           FontWeight="Bold"/>
                    </Grid>
                </DataTemplate>
            </gauges:MarkerGaugeIndicator.MarkerTemplate>
        </gauges:MarkerGaugeIndicator>


         <gauges:MarkerGaugeIndicator Value="57.67"
                                             gauges:LinearGaugeRange.IndicatorOffset="40"
                                             x:Name="indicator7"
                                             IsAnimated="True"
                                             IsMarkerRotated="False">
            <gauges:MarkerGaugeIndicator.MarkerTemplate>
                <DataTemplate>
                    <Grid Width="37"
                                  Height="37">
                        <TextBlock x:Name="txt3" Text="{Binding ZCord}"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Center"
                                           FontSize="13"
                                           FontWeight="Bold"/>
                    </Grid>
                </DataTemplate>
            </gauges:MarkerGaugeIndicator.MarkerTemplate>
        </gauges:MarkerGaugeIndicator>

有人说我如何将坐标值与控件绑定。

4

0 回答 0