MVVM Command in Datatemplate - c#

I have in my XAML a Datatemplate like this:
<DataTemplate x:Key="SheetToTemplate">
<TextBox Name="_txtToSheet"
Text="{Binding Path=SHEET_TO, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource DigitOnlyTextBoxStyle}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=DataContext.FilterTextChangedCommand }" >
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
</DataTemplate>
This is my viewmodel with essential part:
RelayCommand _filterTextChangedCommand;
public ICommand FilterTextChangedCommand
{
get
{
if (_filterTextChangedCommand == null)
{
_filterTextChangedCommand = new RelayCommand(
param => TextChange(param),
param => true);
}
return _filterTextChangedCommand;
}
}
private object TextChange(object param)
{
throw new NotImplementedException();
}
This is the error I get in output:
System.Windows.Data Error: 4 : Cannot find source for binding with
reference 'RelativeSource FindAncestor,
AncestorType='System.Windows.Controls.UserControl',
AncestorLevel='1''.
BindingExpression:Path=DataContext.FilterTextChangedCommand;
DataItem=null; target element is 'InvokeCommandAction'
(HashCode=46858895); target property is 'Command' (type 'ICommand')
I don't understand why the event isn't fired.
Any suggestion?
ps. Note that the property of the textbox is correctly bound.
EDIT
here the full control
<ListView Grid.Row="0"
ItemsSource="{Binding Path=SelectedOperations}"
Margin="5,10,5,5"
Name="WorkOrders"
SelectionMode="Single"
FontSize="13"
Background="AliceBlue"
BorderBrush="AliceBlue">
<!--Style of items-->
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<!--Properties-->
<Setter Property="Control.HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Control.VerticalContentAlignment" Value="Center" />
<!--Trigger-->
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView >
<GridViewColumn Header="Operation" CellTemplate="{StaticResource DetailIdenTemplate}" Width="300"/>
<GridViewColumn Header="From" CellTemplate="{StaticResource SheetFromTemplate}" Width="50"/>
<GridViewColumn Header="To" CellTemplate="{StaticResource SheetToTemplate}" Width="50" />
</GridView>
</ListView.View>
</ListView>
And here the ViewModel class definition:
public class OperativeSheetSelectionViewModel : ViewModelBase
{
//
}

I did it.
The error was on the AncestorType. I need a Window, not an UserControl. (...)

Related

WPF Styling ContentControl in Listview

I have this style for ContentControl:
<UserControl.Resources>
<DataTemplate x:Key="textbox">
<TextBox Text="edit me"/>
</DataTemplate>
<DataTemplate x:Key="textblock">
<TextBlock Text="can't edit"/>
</DataTemplate>
<Style x:Key="ContentControlStyle" TargetType="{x:Type ContentControl}">
<Setter Property="Content" Value="{Binding}"/>
<Setter Property="ContentTemplate" Value="{StaticResource textblock}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListViewItem},AncestorLevel=1}}"
Value="True">
<Setter Property="ContentTemplate" Value="{StaticResource textbox}" />
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
And that codes:
<ListView.View>
<GridView x:Name="UGridview1">
<GridViewColumn Width=" 90">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ContentControl >
</ContentControl>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
But I want to create the columns dynamically, so I wrote the following codes:
for (x = 0; x <= Lvobj.obj.Length - 1; x++) // ClmnCount - 1
{
GridViewColumn_ = new GridViewColumn();
GridViewColumn_.SetValue(NameProperty, "Column" + x);
GridViewColumn_.Header = Lvobj.obj(x)(clmntxt);
GridViewColumn_.Width = 99;
/// This part doesnt work
ContentControl cntr = new ContentControl();
cntr.Style = this.Resources("ContentControlStyle");
///
GridViewColumn_.CellTemplate = cntr.ContentTemplate;
UGridview1.Columns.Add(GridViewColumn_);
}
It never works. What must i do for i can create columns with ContentControl Style?
Either use XamlReader.Parse API with a DynamicResource:
const string Xaml = #"<DataTemplate " +
#"xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> " +
#"<ContentControl Style=""{DynamicResource ContentControlStyle}"" />" +
"</DataTemplate>";
DataTemplate DataTemplate_ = System.Windows.Markup.XamlReader.Parse(Xaml) as DataTemplate;
GridViewColumn_.CellTemplate = DataTemplate_;
Or create a FrameworkElementFactory:
FrameworkElementFactory cc = new FrameworkElementFactory(typeof(ContentControl));
cc.SetValue(ContentControl.StyleProperty, this.Resources["ContentControlStyle"]);
GridViewColumn_.CellTemplate = new DataTemplate() { VisualTree = cc };
Access the ResourceDictionary with square brackets (it's a Dictionary):
this.Resources["ContentControlStyle"]
Make sure to not lookup the style before UserControl.OnInitialized is called. You can override OnInitialized in your UserControl and then initialize the ListView. Alternatively handle the Loaded event.
Alternatively (recommended), consider to define the style implicit (without a x:key). Then the style will be applied automatically, once the target is loaded. This way you don't have to deal with the resources.
You can limit the scope by defining it inside the ResourceDictionary of the ListView:
<ListView>
<ListView.Resources>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="Content"
Value="{Binding}" />
<Setter Property="ContentTemplate"
Value="{StaticResource textblock}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ListViewItem},AncestorLevel=1}}"
Value="True">
<Setter Property="ContentTemplate"
Value="{StaticResource textbox}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<ListView.View>
<GridView x:Name="UGridview1">
<GridViewColumn Width=" 90">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ContentControl />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

Wpf MVVM Selecting/unSelecting Item in DataGrid

I'm working on an MVVM project and I have this Code in one of the the views:
<GroupBox Header="Defaut" BorderBrush="#FF4EA8DE" FontSize="16" Foreground="#FF436EFF" >
<DataGrid Background="Transparent" FontSize="14" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" AutoGenerateColumns="False" Style="{x:Null}"
ItemsSource="{Binding ErrorList}">
<DataGrid.Columns>
<DataGridTextColumn Width="0.5*" Header="{DynamicResource Numéro Cordon}" Binding="{Binding BeadName}"></DataGridTextColumn>
<DataGridTextColumn Width="0.5*" Header="{DynamicResource Indice Image}" Binding="{Binding IndiceImage}"></DataGridTextColumn>
<DataGridTextColumn Width="0.5*" Header="{DynamicResource Défaut}" Binding="{Binding DispDefault}"></DataGridTextColumn>
<DataGridTemplateColumn Header="{DynamicResource Criticité}" Width="0.5*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Label Content="{Binding IsError, Converter={StaticResource IsErrorToCriticityLevel}, Mode=OneWay}"></Label>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="CmdB:CommandBehavior.Event" Value="MouseDown" />
<Setter Property="CmdB:CommandBehavior.Command" Value="{Binding DataContext.RobotErrorSelectionChangedCommand,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type controls:MetroWindow}}}"/>
<Setter Property="CmdB:CommandBehavior.CommandParameter" Value="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="BorderBrush" Value="#FF6593CF" />
<Setter Property="Background" Value="#FF6593CF" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RobotErrorSelectionChangedCommand}" CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGrid>
</GroupBox>
What I want to do is to be able to unselect the selected item in this list, however I can't find how to access it.
Here is the code in the ViewModel related to this list:
ObservableCollection<Erreur> _ErrorList;
public ObservableCollection<Erreur> ErrorList
{
get { return _ErrorList; }
set { _ErrorList = value; RaisePropertyChanged("ErrorList");}
}
private RelayCommand<Erreur> _RobotErrorSelectionChangedCommand;
public RelayCommand<Erreur> RobotErrorSelectionChangedCommand
{
get
{
return _RobotErrorSelectionChangedCommand
?? (_RobotErrorSelectionChangedCommand = new RelayCommand<Erreur>(
(Erreur err) =>
{
if (err != null)
{
viewservice.OpenDialog(new ErreurImageViewModel(err), ServiceLocator.Current.GetInstance<MainViewModel>());
}
}));
}
}
Thank you for any help or advice.
You can bind the SelectedItem property in the Datagrid to a property in the VM, and to clear the current selection you can just set the property to: null. That way you can deselect the SelectedItem through the code whenever you want.
You would bind it in your View like this:
<DataGrid ItemsSource="{Binding ErrorList}" SelectedItem="{Binding SelectedError}" ...>
Then in your ViewModel you would add:
private Erreur _selectedError = null;
public Erreur SelectedError
{
get => _selectedError;
set
{
if (_selectedError == value) return;
_selectedError = value;
RaisePropertyChanged(nameof(SelectedError));
}
}
Whenever you want to clear the selection you can just do:
SelectedError = null;
And if you want to select a specific instance from the code you can do:
SelectedError = myInstanceOfError;
Bind the SelectedError property to the SelectedItem Attribute in your XAML.
XAML:
<DataGrid Background="Transparent" FontSize="14" CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True" AutoGenerateColumns="False" Style="{x:Null}" ItemsSource="{Binding ErrorList}" SelectedItem="{Binding SelectedError}">
C# Property:
private Erreur _SelectedError;
public Erreur SelectedError
{
get { return _SelectedError; }
set {
if(_SelectedError != value)
{
_SelectedErrorList = value;
RaisePropertyChanged("SelectedError");
}
}
}
Thank you, both answers are correct with a little modification, I added the :
SelectedItem="{Binding SelectedError}" in the XAML code.
and I had to comment this part to disable the command from working :
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RobotErrorSelectionChangedCommand}" CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
now the SelectedError get the Selected Item.Thanx

Data binding from a complex ICollectionView in a WPF ItemContainerStyle

I have the following xaml:
<UserControl ... xmlns:dd="clr-namespace:AttachedBehaviours.DragDrop;assembly=AttachedBehaviours" ... >
<UserControl.Resources>
<dd:BindingProxy x:Key="library_proxy"
Binding="{Binding SelectedItems.Count, ElementName=library}" />
</UserControl.Resources>
<ListView x:Name="library" ItemsSource="{Binding View}">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" />
</GridView.Columns>
</GridView>
</ListView.View>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="dd:DragDropMulti.DragDropPreviewControl">
<Setter.Value>
<dd:DragDropPreviewBase>
<dd:DragDropPreviewBase.Template>
<ControlTemplate TargetType="dd:DragDropPreviewBase">
<TextBlock x:Name="tblk__preview"
Text="{Binding Binding, Source={StaticResource library_proxy}}" />
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Binding, Source={StaticResource library_proxy}}"
Value="1">
<DataTrigger.Setters>
<Setter TargetName="tblk__preview"
Property="Text"
Value="{Binding Name}" />
</DataTrigger.Setters>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</dd:DragDropPreviewBase.Template>
</dd:DragDropPreviewBase>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</UserControl>
The problem I'm having is that if I generate my ICollectionView (the "View" in ItemsSource="{Binding View}") with a basic CollectionViewSource, everything works as expected. E.g.:
View = new CollectionViewSource { Source = Models }.View;
However, if I use something more complex, the Setter binding of the DataTrigger doesn't work. E.g.:
View =
new CollectionViewSource
{
Source =
Models
.Join(
Lookups
, model => model.ID
, lookup => lookup.Key
, (model, lookup) =>
new ComplexModel
{
ID = model.ID,
Name = model.Name,
Value = lookup.Value
}
)
}
.View;
I get the error:
System.Windows.Data Error: 40 : BindingExpression path error: 'Name' property not found on 'object' ''MainWindowViewModel' (HashCode=17911681)'.
MainWindowViewModel is the overall DataContext (outside of the UserControl), so it's as though the DataContext has not been set.
Why would this be the case?

Validation in DataGrid not showing Tooltip

In my xaml I am trying to display errors in Tooltip in a datagrid. The Texblock gets its border red and the grid row shows red "!" to say there is an error but tooptip is not displayed (on hovering the mouse)
xaml is
<Window.Resources>
<!--Error Template to change the default behaviour-->
<ControlTemplate x:Key="ErrorTemplate">
<DockPanel LastChildFill="True">
<Border BorderBrush="Red" BorderThickness="1">
<AdornedElementPlaceholder />
</Border>
</DockPanel>
</ControlTemplate>
<!--To display tooltip with the error-->
<Style TargetType="TextBlock">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<DataGrid Name="grid" HorizontalAlignment="Stretch" ItemsSource="{Binding mMngModelList}" Margin="0,0,0,50" VerticalAlignment="Stretch" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Name">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding Name}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Type">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Type}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding Type}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Range Left">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RangeLeft,ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding RangeLeft, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" Validation.ErrorTemplate="{StaticResource ErrorTemplate}"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
In Code my class implements IDataErrorInfo and the code behind is
public string this[string columnName]
{
get
{
var result = string.Empty;
switch (columnName)
{
case "RangeLeft":
if (RangeLeft == 0)
{
result = "RangeLeft should be greater than zero";
}
break;
}
return result;
}
}
public string Error
{
get
{
StringBuilder error = new StringBuilder();
// iterate over all of the properties
// of this object - aggregating any validation errors
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(this);
foreach (PropertyDescriptor prop in props)
{
String propertyError = this[prop.Name];
if (propertyError != string.Empty)
{
error.Append((error.Length != 0 ? ", " : "") + propertyError);
}
}
return error.Length == 0 ? null : error.ToString();
}
}
Also is there a way that until all validations are satisfied, the ObservableCollection is not updated?
Try this Style :
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>

Checkbox ListView WPF C#

I will start developing for WPF and I have a doubt.
I created a ListView with the Binding property to the next ExtComandaDTO the object. The property in "seleciona" has relationship with a checkbox, but I have following problem.
When I click the checkbox it calls the normal event, but when I change the value of "seleciona" at runtime checkbox in my listview is selected but does not call the event check.
There is missing from Listview to be called the event some attribute?
<ListView x:Name="LvwComanda" Grid.Column="0"
Background="{x:Null}"
Margin="40,36,40,40"
SelectedItem="{Binding SelectedExtComanda}"
ItemsSource="{Binding ObsExtComanda, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.RowSpan="2" >
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Finaliza Comanda" Checked="LvwComandaRowFinalizaComanda_Click" Unchecked="LvwComandaRowFinalizaComanda_Click"></MenuItem>
</ContextMenu>
</ListView.ContextMenu>
<ListView.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding finaliza_pendente}" Value="true">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding finalizada}" Value="true">
<Setter Property="Foreground" Value="DarkViolet" />
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<ListView.View>
<GridView >
<GridViewColumn Width="30">
<GridViewColumn.CellTemplate>
<DataTemplate >
<CheckBox Name="ChkComanda" IsChecked="{Binding seleciona.IsChecked, Mode=TwoWay}" Checked="Checked_LvwComandaRow" Unchecked="Unchecked_LvwComandaRow" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="Auto" Header="Comanda" DisplayMemberBinding="{Binding nr_comanda}"/>
<GridViewColumn Width="Auto" Header="Taxa Servico" DisplayMemberBinding="{Binding taxa_servico}" />
<GridViewColumn Width="Auto" Header="Finalizada" DisplayMemberBinding="{Binding finalizada, Converter={StaticResource ReplaceConvertSimNao}}" />
<GridViewColumn Width="Auto" Header="Observacao" DisplayMemberBinding="{Binding observacao}"/>
</GridView>
</ListView.View>
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1">
<Expander.Header>
<DockPanel>
<DockPanel.ContextMenu>
<ContextMenu Loaded="LvwComandaHeaderContextMenu_Loaded">
<MenuItem Header="Libera Mesa" Checked="LvwComandaHeaderLiberaMesa_Click" Unchecked="LvwComandaHeaderLiberaMesa_Click" />
</ContextMenu>
</DockPanel.ContextMenu>
<CheckBox x:Name="HeaderCheckBox" Checked="Checked_LvwComandaHeader" Unchecked="Unchecked_LvwComandaHeader">
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Name, Converter={StaticResource ReplaceConvertMesaId}}" Margin="5,0,0,0"/>
<TextBlock Width="Auto" Text=" " />
<TextBlock FontWeight="Bold" Width="Auto" Text="{Binding Name, Converter={StaticResource ReplaceConvertMesaGrupo}}" />
<TextBlock Text=" ("/>
<TextBlock Text="{Binding ItemCount, Converter={StaticResource ReplaceConvertComanda}}"/>
<TextBlock Text=")"/>
</StackPanel>
</CheckBox>
</DockPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ListView.GroupStyle>
</ListView>
#region Event List Row Comanda
private void Checked_LvwComandaRow(object sender, RoutedEventArgs e)
{
this.Handle_LvwComandaRow((CheckBox)sender, true);
}
private void Unchecked_LvwComandaRow(object sender, RoutedEventArgs e)
{
this.Handle_LvwComandaRow((CheckBox)sender, false);
}
private void Handle_LvwComandaRow(CheckBox sender, bool check)
{
if (sender.DataContext is ExtComandaDTO)
{
var row = (ExtComandaDTO)sender.DataContext;
if (check)
{
ObsExtComanda.FindAll(c => c.seleciona && c.id_mesa != row.id_mesa).ForEach(c => c.seleciona = false);
}
bool bolComandaSelected = ObsExtComanda.Exists(c => c.seleciona);
BtPagamento.IsEnabled = bolComandaSelected;
BtImprimir.IsEnabled = bolComandaSelected;
this.PrepareObsPedido(check, row);
this.PrepareObsComandaPagto(check, row);
}
}
public class ExtComandaDTO : ComandaDTO, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(String property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
private Boolean _seleciona;
private Boolean _finaliza_pendente;
public Boolean seleciona
{
get { return _seleciona; }
set { _seleciona = value; OnPropertyChanged("seleciona"); }
}
public new Boolean finaliza_pendente
{
get { return _finaliza_pendente; }
set { _finaliza_pendente = value; OnPropertyChanged("finaliza_pendente"); }
}
}
Checked and Unchecked are events fired by the UI (not a set).
Handle that stuff in the set if you want to catch changes from code.

Categories