x:Reference 的替代品是什么? [英] What would be an alternative to x:Reference?

查看:42
本文介绍了x:Reference 的替代品是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下所示的 XAML:

I have XAML that looks as follows:

<DataTemplate x:Key="CdTeThickness">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <StackPanel Grid.Row = "0" Orientation="Horizontal">
                <CheckBox x:Name="DisplayMarkers"   Content="Display Data Points" Margin="8,5,0,5" HorizontalAlignment="Left" IsChecked="False"/>
                <CheckBox x:Name="DisplayIndicator" Content="Display Indicator"   Margin="8,5,0,5" HorizontalAlignment="Left" IsChecked="False"/>
            </StackPanel>

            <vf:Chart Grid.Row = "1" Style="{StaticResource chartStyle}" IndicatorEnabled="{Binding Source={x:Reference DisplayIndicator}, Path=IsChecked}">
                <vf:Chart.Titles>
                    <vf:Title Text="{Binding Chart.ChartTitle}"/>
                </vf:Chart.Titles>

我的理解是 x:Reference 尚未得到广泛支持.但是,这是我能够绑定到所需属性 (DisplayIndi​​cator) 的唯一方法,如屏幕截图所示.有人可以建议替代 x:Reference 在这种情况下有效吗?

My understanding is that x:Reference is not widely supported yet. However, this is the only way I was able to bind to the desired property (DisplayIndicator), as shown in the screen shot. Can someone suggest an alternative to x:Reference that will work in this situation?

推荐答案

通常您可以使用 ElementName 绑定,但是 x:Reference 实际上得到了很好的支持.

Often you can use an ElementName binding, however x:Reference is actually well supported.

{Binding IsChecked, ElementName=DisplayIndicator}

这篇关于x:Reference 的替代品是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆