Click here to Skip to main content
15,887,214 members
Home / Discussions / WPF
   

WPF

 
QuestionUI Validation Problem Pin
Kevin Marois10-Oct-23 13:10
professionalKevin Marois10-Oct-23 13:10 
AnswerRe: UI Validation Problem Pin
Richard Deeming10-Oct-23 22:13
mveRichard Deeming10-Oct-23 22:13 
GeneralRe: UI Validation Problem Pin
Kevin Marois12-Oct-23 7:25
professionalKevin Marois12-Oct-23 7:25 
GeneralRe: UI Validation Problem Pin
Richard Deeming12-Oct-23 21:34
mveRichard Deeming12-Oct-23 21:34 
AnswerRe: UI Validation Problem Pin
Gerry Schmitz12-Oct-23 8:52
mveGerry Schmitz12-Oct-23 8:52 
GeneralRe: UI Validation Problem Pin
Kevin Marois12-Oct-23 14:54
professionalKevin Marois12-Oct-23 14:54 
GeneralRe: UI Validation Problem Pin
Gerry Schmitz12-Oct-23 19:12
mveGerry Schmitz12-Oct-23 19:12 
GeneralRe: UI Validation Problem Pin
Kevin Marois16-Oct-23 12:50
professionalKevin Marois16-Oct-23 12:50 
OK, I don't get what's wrong here.

Here's the CustomerName in my CustomerView
<TextBox Grid.Row="1" 
            Grid.Column="0"
            Text="{Binding Customer.CustomerName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
            IsEnabled="{Binding AreFieldsEnabled}">

<pre>
<Validation.ErrorTemplate>
    <ControlTemplate>
        <StackPanel>
            <AdornedElementPlaceholder/>
            <ItemsControl ItemsSource="{Binding}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding ErrorContent}" Foreground="Red" />
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
    </ControlTemplate>
</Validation.ErrorTemplate>



Here's the VM
private void Customer_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
    IsChanged = true;

    ValidateCustomerName();
}

private void ValidateCustomerName()
{
    ClearErrors(nameof(Customer.CustomerName));

    if (string.IsNullOrWhiteSpace(Customer.CustomerName))
    {
        AddError(nameof(Customer.CustomerName), "The Customer Name cannot be empty.");
    }
}
When I clear out the CustomerName field, the ValidateCustomerName method fires, and the error is added to the errors collection. I just don't see the error text on the UI.

However, if instead of binding to Customer.CustomerName, if I put a string property on the VM called CustomerName and use that, then I see the error text.
In theory, theory and practice are the same. But in practice, they never are.”
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.

QuestionUI Validation Questions Pin
Kevin Marois29-Sep-23 15:54
professionalKevin Marois29-Sep-23 15:54 
AnswerRe: UI Validation Questions Pin
Richard Deeming1-Oct-23 21:43
mveRichard Deeming1-Oct-23 21:43 
QuestionCustom Control Style Question Pin
Kevin Marois14-Sep-23 12:35
professionalKevin Marois14-Sep-23 12:35 
AnswerRe: Custom Control Style Question Pin
Gerry Schmitz14-Sep-23 12:57
mveGerry Schmitz14-Sep-23 12:57 
GeneralRe: Custom Control Style Question Pin
Kevin Marois15-Sep-23 5:33
professionalKevin Marois15-Sep-23 5:33 
GeneralRe: Custom Control Style Question Pin
Gerry Schmitz15-Sep-23 5:58
mveGerry Schmitz15-Sep-23 5:58 
GeneralRe: Custom Control Style Question Pin
Kevin Marois15-Sep-23 14:54
professionalKevin Marois15-Sep-23 14:54 
Question.Net Core System.Windows.Data Namespace Pin
Kevin Marois6-Sep-23 17:51
professionalKevin Marois6-Sep-23 17:51 
AnswerRe: .Net Core System.Windows.Data Namespace Pin
Richard Deeming6-Sep-23 21:19
mveRichard Deeming6-Sep-23 21:19 
QuestionLinux - Make an overlay or something like this... Pin
Alex 5326-Aug-23 23:02
Alex 5326-Aug-23 23:02 
QuestionNavigationControl - Still Have A Problem Pin
Kevin Marois25-Aug-23 11:30
professionalKevin Marois25-Aug-23 11:30 
Question[Solved/Workaround] Floating progress visualization with button control Pin
Evilfish20009-Aug-23 23:28
Evilfish20009-Aug-23 23:28 
AnswerRe: Floating progress visualization with button control Pin
Richard Deeming10-Aug-23 0:26
mveRichard Deeming10-Aug-23 0:26 
GeneralRe: Floating progress visualization with button control Pin
Evilfish200010-Aug-23 0:47
Evilfish200010-Aug-23 0:47 
AnswerRe: Floating progress visualization with button control Pin
Gerry Schmitz10-Aug-23 6:11
mveGerry Schmitz10-Aug-23 6:11 
QuestionWPF EF Core 6 DP Question Pin
Kevin Marois24-Jul-23 14:42
professionalKevin Marois24-Jul-23 14:42 
AnswerRe: WPF EF Core 6 DP Question Pin
Richard Deeming24-Jul-23 21:36
mveRichard Deeming24-Jul-23 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.