【问题标题】:Use a Command to set a property on another control all in XAML使用命令在 XAML 中的另一个控件上设置属性
【发布时间】:2012-06-12 16:55:59
【问题描述】:

这看起来应该很简单。但我找不到任何匹配的问题,所以这里是:

假设我有一个按钮:

<Button>Press Me</Button>

而且我有一个第三方标签控件

<SomeTabControl x:Name="myTabControl" IsSelected="False">
   <TextBlock>Stuff Here</TextBlock>
</SomeTabControl>

如何连接该按钮的命令,以便使用仅使用 XAMLIsSelected 设置为 myTabControl 的 True?

或者有可能吗?

【问题讨论】:

    标签: .net wpf xaml binding .net-4.0


    【解决方案1】:

    你可以试试这样的:

    <Button x:Name="button1" Content="Press Me" >
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Click">
                <ei:ChangePropertyAction TargetObject="{Binding ElementName=myTabControl}"
                    PropertyName="IsSelected" Value="True"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </Button>
    

    这要求您将microsoft.expression.interactions.dll 程序集的引用添加到您的项目中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2011-03-12
      • 2017-06-29
      • 1970-01-01
      • 2010-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多