如何在带有 Usercontrol 的 Lisview 中使用 DelegateCommand?在我的 Listview 中,我这样使用它:
<ListView x:Name="peopleListBox">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<UserControls:ItemTemplateControl QuestionText="{Binding parametr}"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
<ListView>
我正在用户控件中尝试:
<Button Content="Click" Command="{Binding Path=DataContext.OpenCommand, ElementName=peopleListBox}"/>
和这个:
<Button Content="Click" Command="{Binding Path=OpenCommand, ElementName=peopleListBox}"/>
这两个代码都不起作用。
用户控制:
<UserControl
x:Class="App13.UserControls.ItemTemplateControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local1="using:App13"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Button Content="Click" Foreground="Black" Command="{Binding Path=DataContext.OpenCommand, ElementName=peopleListBox}"/>
</Grid>
</UserControl>