Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Binding and Validation
    primarykey
    data
    text
    <p>I have an issue with validation in WPF that I can't seem to resolve. I have a class (that implements IDataErrorInfo) that uses a property like-so.</p> <pre><code>private double? _SizeSearchValue; public double? SizeSearchValue { get { return _SizeSearchValue; } set { _SizeSearchValue = value; NotifyChange("SizeSearchValue"); ValidateInputRow("SizeSearchValue"); } } </code></pre> <p>It is bound to a textbox in XAML like this.</p> <pre><code> &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock VerticalAlignment="Center" Text="Size:"/&gt; &lt;ComboBox Text="{Binding SizeSearchOption, ValidatesOnDataErrors=True}"/&gt; &lt;TextBox Text="{Binding SizeSearchValue, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, ValidatesOnExceptions=False}"/&gt; &lt;/StackPanel&gt; </code></pre> <p>The ValidateInputRow() function in the property setter will normally go through and run my custom validation routines and set errors appropriately so that the ComboBox and TextBox in the StackPanel mention above have a red border. Everything works just fine until I put a non-numeric string into the Textbox ("Abc" for example.)</p> <p>With string input the binding runs its default validation, a FormatException is raised and the textbox gets its red border as per usual. My problem with this is that my custom validation routine will never run because the property setter in my class is never called. </p> <p>I understand why this is happening, but I was wondering if anyone knew a way to catch an event, or the offending FormatException so that I can run my custom validation after the fact. I can't seem to figure this one out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload