名称解决了TargetedTriggerAction的问题 [英] Name resolve issue with TargetedTriggerAction
问题描述
为了在点击按钮后关闭上下文菜单项我打算使用
Microsoft.Expression.Interactivity.Core .ChangePropertyAction 类设置"IsSubmenuClosed"其父 item (其名称为"CustomBackgroundMenuItem",见下面的代码)的属性为false。我尝试了不同的绑定,但它们似乎没有
,因为触发器操作无法解析正确的目标对象。它始终设置为动作附加到的按钮("AssociatedObject")而不是命名的MenuItem。有人可以帮帮我吗?
In order to close a context menu item after clicking a button I intended to use the Microsoft.Expression.Interactivity.Core.ChangePropertyAction class to set the "IsSubmenuClosed" property of its parent item (which is named "CustomBackgroundMenuItem", see code below) to false. I tried different bindings but none of them seem to work, as the trigger action isn't able to resolve the right target object. It is always set to the Button the action is attached to (the "AssociatedObject") instead of the named MenuItem. Can anybody help me?
<ContextMenu>
<MenuItem x:Name="CustomBackgroundMenuItem" Header="Hintergrundfarbe">
<MenuItem StaysOpenOnClick="True">
<MenuItem.Header>
<StackPanel>
<ColorSelectors:ColorPicker CurrentColor="{Binding Path=CustomBackground, Mode=TwoWay, TargetNullValue={x:Static Colors.White}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Abbrechen">
<Interactivity:Interaction.Triggers>
<Interactivity:EventTrigger EventName="Click">
<!-- NOTE: Doesn't find element "CustomBackgroundMenuItem" ! -->
<Core:ChangePropertyAction TargetName="CustomBackgroundMenuItem" PropertyName="IsSubmenuOpen" Value="False" />
</Interactivity:EventTrigger>
</Interactivity:Interaction.Triggers>
</Button>
</StackPanel>
</StackPanel>
</MenuItem.Header>
</MenuItem>
</MenuItem>
</ContextMenu>
推荐答案
您好,¥b $ b
我很高兴 看到你的问题,类似的解决方案就是我在博客上发布的博客,这可能会帮助你做很多事情
Hello ,
I am glad to see your question, similar solution is what I have blogged on my blog and that might help you a lot in doing very stuff
这是我的博客,
http://www.expression-blend.com
我希望它帮助你!
问候,
这篇关于名称解决了TargetedTriggerAction的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!