Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
xamdatagrid with control template for delete row with MVVM
posted

Hi,

I have problem with using control template definition for deleting row. code below for style and control template xaml:

<UserControl x:Class="natbase.View.AllCustomersView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"   
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:igEditors="http://infragistics.com/Editors"
d:DesignHeight="600" d:DesignWidth="976">


<!-- USERCONTROL RESOURCES-->
<UserControl.Resources>
<!-- DELETE BUTTON STYLE-->
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="deleteButtonStyle">
<Setter Property="Visibility" Value="Collapsed"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Command="{Binding DeleteCommand}">
  <Image Source="/natbase;component/Images/delete_48.png" HorizontalAlignment="Center"
Width="20" Height="20">
</Image>
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=IsActive}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsMouseOver,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type igDP:DataRecordPresenter}}}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>

column definition in xamdatagrid:

<igDP:UnboundField >
<igDP:UnboundField.Settings>
<igDP:FieldSettings
AllowResize="False"
AllowGroupBy="False"
AllowRecordFiltering="False"
AllowSummaries="False"
CellWidth="20"
LabelWidth="20"
CellValuePresenterStyle="{StaticResource deleteButtonStyle}"/>
</igDP:UnboundField.Settings>
</igDP:UnboundField>

 

DeleteCommand in ViewModel is just displaying messagebox with delete message for now. Problem is that DeleteCommand bound to the button in control template is not working. Simply nothing happens, message box is not displayed, click event is not handled. Can you help me with that?