3

I'm trying to setup validation for some form fields and bind any errors to the UI elements provided by materialdesign-in-xaml.

The question is how can I use reactive's Bind method to set the required parameters (not sure if parameters is the correct wording here) for this to work.

I'm trying to do this:

<TextBox x:Name="NewTransactionPriceTextBox"
         Margin="0,15,0,0"
         materialDesign:HintAssist.Hint="Transaction Price" 
         HorizontalAlignment="Left"
         Text="{Binding NewTransactionPrice, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />

But in code behind, like this:

this.Bind(ViewModel, vm => vm.NewTransactionPrice, 
             v => v.NewTransactionPriceTextBox.Text).DisposeWith(sub);

How can I pass NotifyOnValidationError=True and the rest using ReactiveUI Syntax?

Tobias Tengler
  • 6,848
  • 4
  • 20
  • 34
alpha07
  • 31
  • 1
  • Have you checked out the ReactiveUI validation project. https://GitHub.com/ReactiveUI/ReactiveUI.validation – Glenn Watson Jul 11 '19 at 01:58
  • 1
    @GlennWatson hi. I did check it out, but regardless of the validation mechanism my question would be the same, how to trigger a user control validation error event on each control that failed validation. The examples in ReactiveUI.validation that I saw populate a separate property that map to a different Control to display the validation issues to the user, which is indeed a valid workaround. But with this I can't leverage the automatic theming from MaterialDesignThemes to populate each validation error in its own Control Element. – alpha07 Jul 11 '19 at 19:09
  • I'm running into this same issue and I'm wondering if you ever figured out a way to do it. It seems that validation can only occur via XAML binding, but reactiveui provides its own binding methods that don't seem to support it. Setting the validation on a separate control seems really hacky. – Skrymsli May 19 '20 at 00:46
  • Never did figure it out unfortunately. Ended up dropping this framework from my project. Insufficient documentation on many of the features. – alpha07 May 20 '20 at 01:10

0 Answers0