<DataGridTemplateColumn Header="Edit" IsReadOnly="True" MinWidth="40" Width="*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="btnedit" Width="25" Height="25" Command="{Binding BanquetSearchCommand, ElementName=LayoutRoot}" CommandParameter="{Binding Id}">
<!--<Button.CommandParameter>
<MultiBinding Converter="{StaticResource ResourceKey=BanquetValuConverter}">
<Binding StringFormat="hi"></Binding>
</MultiBinding>
</Button.CommandParameter>-->
<Image Width="25" Height="15" Source="/TBC;component/images/Edit_N1.png" ></Image>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Delete" IsReadOnly="True" MinWidth="40" Width="*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="btnDelete" Width="25" Height="25">
<Image Width="25" Height="15" Source="/TBC;component/images/Delete_N1.png"></Image>
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Border>
<Border CornerRadius="3" BorderBrush="Black" BorderThickness="1" Grid.Row="3" >
<StackPanel Grid.Row="5" Orientation="Horizontal" Margin="300 0 0 0" Height="100">
<Button Content="Add" Foreground="White" Height="23" Margin="38 38 0 38" HorizontalAlignment="Left" Name="btnAdd" VerticalAlignment="Top" Width="75" Command="{Binding BanquetSearchCommand}" >
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource ResourceKey=BanquetValuConverter}">
<Binding ElementName="btnAdd" Path="Content"/>
<Binding ElementName="btnRefresh" Path="Content"/>
</MultiBinding>
</Button.CommandParameter>
<Button.Background>
<ImageBrush ImageSource="/TBC;component/images/Add.png" Stretch="UniformToFill" TileMode="None" />
</Button.Background>
</Button>
<Button Content=" Refresh" Foreground="White" Height="23" Margin="20 38 0 38" HorizontalAlignment="Left" Name="btnRefresh" VerticalAlignment="Top" Width="75">
<Button.Background>
<ImageBrush ImageSource="/TBC;component/images/Refresh.png" Stretch="UniformToFill" TileMode="None" />
</Button.Background>
</Button>
<Button Content="Exit" Foreground="White" Height="23" Margin="20 38 0 38" HorizontalAlignment="Right" Name="btnExit" VerticalAlignment="Top" Width="75">
<Button.Background>
<ImageBrush ImageSource="/TBC;component/images/Exit.png" Stretch="UniformToFill" TileMode="None" />
</Button.Background>
</Button>
</StackPanel>
</Border>
上は私が持っているxamlで、編集と削除のボタンコマンドをクリックするとデータグリッドのテキスト列データが必要です.そして下はビューモデルです
public ICommand BanquetSearchCommand { get; set; }
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
//var param = (Tuple<string, string>)parameter;
List<string> lststring = parameter as List<string>;
string operation = string.Empty;
string datarowindex = string.Empty;
operation = Convert.ToString(lststring[0]).Trim();
datarowindex = Convert.ToString(lststring[1]).Trim();
switch (operation)
{
case "Add":
BlanquetMaster _bnkmaster = new BlanquetMaster();
_bnkmaster.ShowDialog();
break;
case "Refresh":
break;
case "Close":
break;
}
}
Execute()を実行しない編集ボタンとして私を導いてください。私は新しい新しい WPF です。