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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:14:09+00:00 2026-05-23T05:14:09+00:00

The Problem: I am creating user control that handles data conversions (via a converter/validation

  • 0

The Problem:
I am creating user control that handles data conversions (via a converter/validation rule). This works 100% as desired, but the validation only fires when the control is bound to something, which is not always the case.

Is there a way to force validation even if the control is not bound? OR is there a way to set up basically a dummy binding. (The solution needs to be done in code so that the end result is a drag and drop user control with no xaml customization needed by the programmer.

Thanks in advance for any advice.

EDIT : Really the code in question is this:

Binding TextBinding = BindingOperations.GetBinding(this, TextBox.TextProperty);
TextBinding.ValidationRules.Add(MyValidationRule);

This is how I am assigning my validation rule, but it will only work if the TextBinding is not null. So I either need a dummy binding for my TextBox, or another way to add the validation rule.

  • 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-23T05:14:09+00:00Added an answer on May 23, 2026 at 5:14 am

    Sounds to me like what you want to be doing is defining a dependency property on your user control which the XAML in your user control binds to. This binding would incorporate your validation rule. Consumers of your user control would then bind the property on your user control to whatever they want.

    It’s really hard to be more specific than that without your exact use case, but consider this:

    CoolUserControl.xaml.cs:

    public class CoolUserControl : UserControl
    {
        public static readonly DependencyProperty CoolProperty = ...;
    
        public string Cool
        {
            // get / set
        }
    }
    

    CoolUserControl.xaml:

    <UserControl x:Name="root" ...>
        <TextBox>
            <TextBox.Text>
                <Binding Path="Cool" ElementName="root">
                    <Binding.ValidationRules>
                        <!-- your rule here -->
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
    </UserControl>
    

    SomeConsumer.xaml:

    <local:CoolUserControl Cool="{Binding SomePropertyOnMyViewModel}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a user control in ASP.NET (using VB) that uses the autocomplete
I'm troubleshooting a problem with creating Vista shortcuts. I want to make sure that
I am facing a problem while creating a static cursor in DB2. This is
This problem is similar to when creating alternate colour table-rows, only we are dealing
I'm creating user controls that i will put into an update panel and make
I'm working on creating a date/time user control in WPF using C# 2008. My
I am creating a web user control for showing Alert on AspxGridView Columns(Delete/Edit) click
I have a little problem with the creation of a user control. Though I
I'm creating a web user control and want to get some html from a
I'm having a problem with the WPF Tab View control that I was hoping

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.