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

  • Home
  • SEARCH
  • 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 548241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:03:30+00:00 2026-05-13T11:03:30+00:00

I am trying to use in WPF a validating input of databound controls with

  • 0

I am trying to use in WPF a validating input of databound controls with validation rules. In the code behind file of a wpf window I have a class:

public class posintValidationRule : ValidationRule
{
    public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
    {
        string _strInt = value.ToString();
        int _int = -1;
        if (!Int32.TryParse(_strInt, out _int))
            return new ValidationResult(false, "Value must be an integer");
        if (_int < 0)
            return new ValidationResult(false, "Value must be positive");
        return new ValidationResult(true, null);
    }
}

In XAML there is also a style error template.

When I put a textbox with validation in XAML:

<TextBox.Text>
    <Binding Path="seconds" UpdateSourceTrigger="PropertyChanged">
        <Binding.ValidationRules>
           <local:posintValidationRule/> 
        </Binding.ValidationRules>
    </Binding>
</TextBox.Text>

I get a compile time error:
”local’ is an undeclared namespace.’ XML is not valid.

How I should declare local:posintValidationRule in my XAML?

  • 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-05-13T11:03:30+00:00Added an answer on May 13, 2026 at 11:03 am

    At the top of your XAML file, you need to declare what your “local” namespace is; alongside the default Microsoft XAML stuff. Something like this:

    xmlns:local="clr-namespace:YourApplication"
    

    Note this assumes that “posintValidationRule” is defined at the root namespace in “YourApplication”.

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

Sidebar

Related Questions

I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown
I've been trying to use the WPF toolkit in a WPF application that I'm
I'm trying to use the FolderBrowserDialog from my WPF application - nothing fancy. I
I am trying to adapt a simple WPF application to use the Model-View-ViewModel pattern.
Trying to use an excpetion class which could provide location reference for XML parsing,
While trying to use LINQ to SQL I encountered several problems. I have table
Since I am trying to learn WPF I see more and more the use
I'm trying to use a WPF application on our Citrix server, and made a
So I'm trying to use a WPF User Control to generate a ton of
Ok, So I have been stalled in my latest non-work project, trying to use

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.