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 7883941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:40:03+00:00 2026-06-03T04:40:03+00:00

I have a registration form with few fields. It´s a PRISM MVVM application. XAML

  • 0

I have a registration form with few fields. It´s a PRISM MVVM application.

XAML of one of the field looks like this (RegisterView.xaml):

<TextBlock>Surname</TextBlock>
<TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}"      HorizontalAlignment="Left" Margin="0" Name="Surname" VerticalAlignment="Top" >
    <TextBox.Text>
        <Binding Path="Surname" UpdateSourceTrigger="LostFocus" >
            <Binding.ValidationRules>
                 <val:Required />
            </Binding.ValidationRules>
        </Binding>
    </TextBox.Text>
</TextBox>

As you can see from the code above, I use class Required to validate the field. Function Validate() of class Required then returns ValidationResult object. I also defined some triggers to styles for inputs, so I´m able to show validation result to the user in view.

What I don’t know is how to detect the state of validation of all the inputs in ViewModel. In the ViewModel, I have the SaveUserCanExecute function which should enable/disable registration form submit button on the basic on a validation state of all the inputs.

So is there any simple way how to achieve this?

I could make some workaround for this, but I think is not the proper way.

Now I made a Submit_Click function in a View code behind fired on a Click event of a Submit Button.

In RegisterView.xaml

<Button Content="Register" HorizontalAlignment="Left" Margin="0" Name="Submit" VerticalAlignment="Top" Command="{x:Static inf:Commands.SaveUser}" Click="Submit_Click" />

I also created new public boolean variable “formIsValid” in code behind. When submit button is pressed, then I check whether all inputs has no validation error (with Validation.GetHasError(InputName) function). If so, I set the formIsValid variable to true, otherwise, I set it to false.

In RegisterView.xaml.cs

private void Submit_Click(object sender, RoutedEventArgs e)
{
    if (Validation.GetHasError(Firstname) == false && Validation.GetHasError(Surname) == false)
    {
        registerFormValid = true;
    }
    else
    {
        registerFormValid = false;
    }
}

Then in ViewModel SaveUserCanExecute function looks like this:

private bool SaveUserCanExecute(string parameter)
{
    if (View.registerFormValid == true)
    {
        return true;
    }
    return false;
}

But as I mentioned before, I think it´s not the proper way, and I´m looking for some more clear way.

  • 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-03T04:40:05+00:00Added an answer on June 3, 2026 at 4:40 am

    implement IDataErrorInfo in your ViewModel then you have all information you need in your VM. Your XAML just need the ValidatesOnDataErrors=true

    <TextBlock>Surname</TextBlock>
    <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}"      HorizontalAlignment="Left" Margin="0" Name="Surname" VerticalAlignment="Top" >
            <TextBox.Text>
                <Binding Path="Surname" UpdateSourceTrigger="LostFocus" ValidatesOnDataErrors="True">
                </Binding>
            </TextBox.Text>
     </TextBox>
    

    EDIT: check the use of DelegeCommand and then your command CanExecute can simply check then for string.IsNullOrEmpty(this.Error).

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

Sidebar

Related Questions

I have a registration form with a few fields. One of them looks like
in my project i have one registration form which is developed in C#.net.to this
I have this registration form box, and i really like how the background gets
In my web application i have registration form, when user register i want to
I have a registration form with common registration fields and two multiple selection Lists
I have a registration form where this CSS rules apply. when user submits with
I have one registration form, I don't want people to register login username with
Team I'm creating an iphone application using Sencha Touch. I have registration form ,
I have this registration form which is then validated using "bassistance's" validate.js: $('#pForm').validate({ rules:
I have a registration form and am using $.ajax to submit it. This is

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.