大家好,我的表单中有可消耗的列表,我想将点击效果绑定到可扩展列表中的项目。到目前为止,一切都很好。我已经设法正确显示可扩展但我无法绑定双击。我在 MVVM Catel 做我的项目。
我的 XAML:
<Grid>
<ItemsControl ItemsSource="{Binding Source={StaticResource cvsRoutes}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Name}" MinHeight="50">
<ListBox>
<TextBlock Text="Something" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<cmd:EventToCommand Command="{Binding OpenNewWindow}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
<TextBlock Text="Something" />
<TextBlock Text="Something" />
<TextBlock Text="Something" />
<TextBlock Text="Something" />
</ListBox>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
在 ModelView 类中我有:
public RouteViewModel(IMessageService messageService,
IPleaseWaitService pleaseWaitService, IMapService mapService)
{
this.mapService = mapService;
OpenNewWindow = new Command(CreateNewWindow);
}
public Command OpenNewWindow { get; private set; }
//Method To Open the new window
public void CreateNewWindow()
{
NewWindow.ShowNewWindowMap();
}