Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7999885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:37:53+00:00 2026-06-04T15:37:53+00:00

Here is the problem: I have a simple form (textboxes, etc). The bindings are

  • 0

Here is the problem:

  1. I have a simple form (textboxes, etc).
    • The bindings are all within a BindingGroup.
    • Each binding has UpdateSourceTrigger=Explicit set.
    • Some bindings have validation rules attached that do not allow blank/null values (required field).
  2. I bind a brand new, empty object to the form.
  3. Without entering any data, the user clicks the save button triggering BindingGroup.UpdateSources().
  4. UpdateSources succeeds, no validation errors are triggered.

I believe this occurs because WPF only triggers the validation rules of each binding if the user has actively changed the value of that field in the UI, and since I originally bound an empty object to the form, nothing has changed. This is not the behavior I want – I want all validation rules to be evaluated when UpdateSources is called.

Does anyone know a (hopefully clean) way to get the behavior I want?


Here is a (shortened, simplified) example of the C# and XAML code:

ToolTypeModelPanel.xaml.cs

private void addModelButton_Click(object sender, RoutedEventArgs e)
{
    ToolModel model = new ToolModel();

    // bind the model details view to the new model
    this.createModelBinding = new Binding();
    this.createModelBinding.Source = model;
    this.modelFormGrid.SetBinding(Grid.DataContextProperty, this.createModelBinding);
}

private void saveModelButton_Click(object sender, RoutedEventArgs e)
{
    Binding modelDataContext = this.modelFormGrid.GetBindingExpression(Grid.DataContextProperty).ParentBinding;

    if (modelDataContext == this.modelDetailsBinding && this.modelListBox.SelectedItem != null)
    {
        // update existing tool model
        if (this.modelFormBindingGroup.UpdateSources())
        {
            // ...
        }
    }
    else if (modelDataContext == this.createModelBinding)
    {
        // create new tool model
        ToolModel modelToCreate = (ToolModel)this.createModelBinding.Source;

        if (this.modelFormBindingGroup.UpdateSources())
        {
            Context.ToolModel.AddObject(modelToCreate);
            Context.SaveChanges();

            // ...
        }
    }
}

ToolTypeModelPanel.xaml

<GroupBox
    Grid.Row="3"
    Grid.Column="2"
    Margin="5"
    Header="{x:Static prop:Resources.HeaderModelDetails}">
    <Grid x:Name="modelFormGrid" DataContext="{Binding ElementName=modelListBox, Path=SelectedItem}">

        <Grid.BindingGroup>
            <BindingGroup x:Name="modelFormBindingGroup" />
        </Grid.BindingGroup>

        <Label Grid.Row="0" Grid.Column="0" Content="{x:Static prop:Resources.LabelModelName}" />
        <TextBox x:Name="modelNameTextBox"
            Grid.Row="0"
            Grid.Column="1">
            <TextBox.Text>
                <Binding Path="ModelName" UpdateSourceTrigger="Explicit">
                    <Binding.ValidationRules>
                        <vr:RequiredValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>

        <Label Grid.Row="3" Grid.Column="0" Content="{x:Static prop:Resources.LabelModelParameter}" />
        <TextBox x:Name="modelParameterTextBox"
            Grid.Row="3"
            Grid.Column="1"
            Text="{Binding Path=ModelParameter, UpdateSourceTrigger=Explicit}" />

        <Label Grid.Row="4" Grid.Column="0" Content="{x:Static prop:Resources.LabelFactoryAssemblyName}" />
        <TextBox x:Name="modelFactoryAssemblyTextBox"
            Grid.Row="4"
            Grid.Column="1">
            <TextBox.Text>
                <Binding Path="FactoryAssemblyName" UpdateSourceTrigger="Explicit">
                    <Binding.ValidationRules>
                        <vr:NamespaceValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>

        <Button x:Name="saveModelButton"
            Width="100"
            Margin="36,0,0,0"
            IsEnabled="False"
            Content="{x:Static prop:Resources.ButtonSaveText}"
            Click="saveModelButton_Click" />
    </Grid>
</GroupBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:37:55+00:00Added an answer on June 4, 2026 at 3:37 pm

    My current workaround is:
    After binding a new item to the form, set fields of the form that need validation to a non-null but empty value for example:

    this.modelNameTextBox.Text = string.Empty;
    

    This causes the WPF validation scheme to validate the binding of this textbox when the sources are updated. If anyone has a cleaner solution please let me know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple stupid question. Here's the problem, for years, my company has
Here is the problem: I have a simple c# form I have a simple
I have a simple problem regarding a loop in a Rails controller. Here's the
here is a simple problem. I have a table of 500 rows and what
I've written this fiddle to demo the problem. I have a simple form. When
Hey all, i have made a simple form that mimiks the jQuery GROWL effect
I have a simple form... <label>name</label><input type=text id=name> <label>email address</label><input type=text id=email> Here is
I have a simple ajax form and I'm trying to validate that it has
I have a simple form that has a list (dropdown list generated from a
new with javascript here. I have a simple form that takes what the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.