I am using xamDataGrid with fields A B and C.
A is numeric, B is enum field, C is unbound field which contains a button inside.
The button is used to change the value of A (let's say to increase by 1)
B is updated from the code behind and depending of B value the button in C should be enabled/disabled.
I am using the following template:
<Style x:Key="OrderGridIncreaseStyle" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{x:Static Themes:DataPresenterGeneric.CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <Button Content="Increase" Command="my:MyClass.increasePrice" CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Record}"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
private static void PriceChangeCanExecute(object sender, CanExecuteRoutedEventArgs e){ var record = e.Parameter as DataRecord; if (record == null) { e.CanExecute = false; return; } var item = record.DataItem as MyCustomClass; if (item == null) { e.CanExecute = false; return; } e.CanExecute = item.Property == SomeValue) ; } The problem is: button IsEnabled state does not change as Field B value changes, it only changes when grid is clicked or keyboard key is pressed. How to make the button enabled state change immediately? the datasource is observablecollection and every property of datasource item implements INotifyPropertyChanged... I can see field B value changing, but button state does not.
private static void PriceChangeCanExecute(object sender, CanExecuteRoutedEventArgs e){ var record = e.Parameter as DataRecord; if (record == null) { e.CanExecute = false; return; } var item = record.DataItem as MyCustomClass; if (item == null) { e.CanExecute = false; return; } e.CanExecute = item.Property == SomeValue) ; }
The problem is: button IsEnabled state does not change as Field B value changes, it only changes when grid is clicked or keyboard key is pressed.
How to make the button enabled state change immediately?
the datasource is observablecollection and every property of datasource item implements INotifyPropertyChanged...
I can see field B value changing, but button state does not.
Could you provide a small isolated sample that demonstrates the problem or modify my sample attached with this post so we can look further into this issue?
Just following up on this thread. Let me know if I can be of further assistance.