0
我試圖通過爲CommandParameter
實際Frame
對象到我施加Command
的RelativeSource綁定找不到框架祖先
XAML
<Frame NavigationUIVisibility="Hidden" Source="{Binding TargetContentPage}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ContentRendered">
<command:EventToCommand Command="{Binding ContentRendered}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Frame}}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Frame>
C#
public RelayCommand<Frame> ContentRendered
{
get
{
return new RelayCommand<Frame>(frame => frame.RemoveBackEntry());
}
}
運行時,一個NullReferenceException
被提出說frame
爲空。 上面的代碼可能有什麼錯誤?
您是否可能缺少Mode = FindAncestor? – Lennart
@Clemens是的,你是對的,我錯過了,請添加它作爲答案請。 – AymenDaoudi