I have View and its ViewModel. In View, I have some Panels that has binding to some properties in my ViewModel;
For example first property is SomeObject
. In that panel I have some textboxes, that has binding to some properties in SomeObject
class. All bindings in ViewModel and classes implements INPC.
That textbox, in panel, has binding to its property in SomeObject
class this way: SomeObject.Property
.
In that view I have a Save button. I need change the IsEnabled
property of my button every time when something was entered in textboxes or changed in panel.
I've done it only for SomeObject
property in my viewmodel by changing IsEnabled
property bound to button from SomeObject's setter. But when I change something in properties of my SomeObject
it doesn't call the setter of main SomeObject
in ViewModel, and I can't change my IsEnabled
property from SomeObject
class.
<controls:ExpandableSettingsPanel Header="REFUND" IsExpanded="{Binding RefundCustomerConfigurationEnabled, Mode=TwoWay}" ..>
<StackPanel..>
<CheckBox Content="Allowed within reversal period" IsChecked="{Binding RefundCustomerConfiguration.IsAllowedWithinReversalPeriod, Mode=TwoWay}"/>
<TextBlock Style="{DynamicResource GrayTextBlockStyle}" Text="Minimal amount to be refunded"/>
<WrapPanel>
<TextBlock Text="€" .. />
<controls:MementoTextBox Text="{Binding RefundCustomerConfiguration.MinimalAmountToBeRefunded, Mode=TwoWay,
NotifyOnValidationError=True, StringFormat=\{0:N2\},
TargetNullValue='',
UpdateSourceTrigger=PropertyChanged,
ValidatesOnNotifyDataErrors=True,
ValidatesOnExceptions=True}" ..>
<i:Interaction.Behaviors>
<behaviors:TextBoxInputRegExBehavior
EmptyValue="0.00"
IgnoreSpace="True"
RegularExpression="^\d{1,2}(\.?\d{1,2})?$"
MaxLength="6"
/>
</i:Interaction.Behaviors>
</controls:MementoTextBox>
</WrapPanel>
<TextBlock Style="{DynamicResource GrayTextBlockStyle}" Text="Minimal bank statement line age" ../>
<controls:MementoTextBox Text="{Binding RefundCustomerConfiguration.MinimalBankStatementLineAge,
Mode=TwoWay,
NotifyOnValidationError=True,
ValidatesOnNotifyDataErrors=True,
UpdateSourceTrigger=PropertyChanged,
ValidatesOnExceptions=True }" ..>
<i:Interaction.Behaviors>
<behaviors:TextBoxInputRegExBehavior
EmptyValue="0"
IgnoreSpace="True"
RegularExpression="^\d{1,3}$"
MaxLength="3"
/>
</i:Interaction.Behaviors>
</controls:MementoTextBox>
</StackPanel>
</controls:ExpandableSettingsPanel>
This is my XAML part.
public RefundCustomerConfiguration RefundCustomerConfiguration
{
get { return _refundCustomerConfiguration; }
set
{
SetProperty(ref _refundCustomerConfiguration, value);
OnPropertyChanged("RefundCustomerConfigurationEnabled");
}
}
[Required(ErrorMessage = "This field is required")]
public bool IsAllowedWithinReversalPeriod
{
get { return GetValue(() => IsAllowedWithinReversalPeriod); }
set
{
SetPropertyValue(value);
}
}
And this is my properties; First - in ViewModel. Second - in first property class.