以下是我的xaml
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListBox x:Name="movieList" ItemsSource="{Binding Path=MovieMain.Movies}" Margin="10">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Column="1" Margin="10">
<StackPanel Orientation="Horizontal">
<Label Content="Selected movie: " Margin="2" />
<Label Content="{Binding Path=SelectedItem.Name, ElementName=movieList}" />
</StackPanel>
<igDP:XamDataGrid x:Name="dataGrid" DataSource="{Binding Path=SelectedItem.Artists, ElementName=movieList}">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:ComboBoxField Name="Name">
<igDP:ComboBoxField.EditorStyle>
<Style TargetType="igEditors:XamComboEditor">
<Setter Property="ItemsSource"
Value="{Binding Path=DataContext.ComboItems, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" />
</Style>
</igDP:ComboBoxField.EditorStyle>
</igDP:ComboBoxField>
<igDP:NumericField Name="Age" />
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</StackPanel>
<Button Grid.Row="1" Grid.Column="0" Width="55" Height="25" Command="{Binding ClickCommand}"/>
</Grid>
在上面,我将Listbox与一个模型绑定,并根据所选项目绑定datagrid。
现在我正在对datagrid进行删除操作。那么我该如何实现删除功能呢?
我创建了一个删除记录的按钮。我们可以通过指定行的命令参数吗?
答案 0 :(得分:0)
试试这个:
<Button ... Command="{Binding ClickCommand}"
CommandParameter="{Binding SelectedDataItems[0], ElementName=dataGrid}" />