1
我的Windows通用頁面上有一個ListView。我用一個用戶控件來定義我的ItemTemplate,這樣我可以使用RelativePanel和VisualStateManager來控制我的項目出現如何根據屏幕尺寸...DataBinding ListView ItemTemplate UserControl
<ListView ItemsSource="{Binding Path=AllThings}"
ItemContainerStyle="{StaticResource ListViewItemStyle}">
<ListView.ItemTemplate>
<DataTemplate>
<local:CrossingControl />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我有我的用戶一個按鈕,我想它的命令綁定到是列表本身的DataContext的視圖模型的命令屬性...
<UserControl ...>
<RelativePanel>
<StackPanel x:Name="crossedEntryPanel">
<Button Command="{Binding DataContext.DeleteCommand,
RelativeSource={RelativeSource Mode=TemplatedParent}}"
CommandParameter="{Binding}"
我已經使用的ElementName約束力的嘗試,但它似乎沒有工作(我想是因爲我的ListView元素名稱在另一個xaml文件中定義)。我也嘗試了上面的RelativeSource綁定,但似乎也沒有工作。我怎樣才能正確地綁定這個?
這是怎麼回事:http://stackoverflow.com/questions/19522202/how-to-call-功能在一個主視圖模型從其他視圖模型 – Alamakanambra
不完全解決我的問題,我害怕。在祖先類型似乎不可用在Windows通用 –
如何在'CrossingControl'內移動'DeleteCommand'? –