将显示视图的框架作为命令参数传递?

时间:2011-07-04 05:01:20

标签: .net wpf xaml .net-4.0

我想知道你是否可以传递包含控件作为命令参数的Frame?

这就是我的尝试:

<Button Grid.Row="2" Content="Save" HorizontalAlignment="Left" Width="100" Command="{Binding Path=SaveOptions}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Frame}}}"></Button>

但是传递给视图模型的参数为null。谁能说出为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

我可以实现此目的的方法是使用ElementName属性。但它真的很有趣,为什么FindAncestor模式不起作用。