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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:59:00+00:00 2026-05-31T10:59:00+00:00

I have a DataGrid and it has a DataGridTextColumn that has items which I

  • 0

I have a DataGrid and it has a DataGridTextColumn that has items which I want to validate based on other cell’s value in the same row. The column is bound to one of data item’s property. Another property of same data item contains something like an input mask. Validation should check new value with the input mask for current row’s data item. That input mask is not edited anywhere on the form (no need to track the input mask changes), but the input mask can be different for each row. So how do I write a custom validator like that? I’ve tried the following:

<DataGridTextColumn Width="*">
                    <DataGridTextColumn.Binding>
                        <Binding Path="Name" Mode="TwoWay" UpdateSourceTrigger="LostFocus" ValidatesOnExceptions="True" NotifyOnValidationError="True" ValidatesOnDataErrors="True">
                            <Binding.ValidationRules>
                                <validation:Class2 ValidatesOnTargetUpdated="True" Format="999" />
                            </Binding.ValidationRules>
                        </Binding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>

And here goes validator code:

 class Class2 : ValidationRule
    {        
        /// <summary>
        /// input mask
        /// </summary>
        public string Format { get; set; }

    /// <param name="value">cell's new value that should be validated against input mask</param>        
    public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
    {
        // validation logic goes here
        return new ValidationResult(true, null);
    }
}

But it appears that I can’t bind Class2.Format property to the data item because Class2 doesn’t inherit from DependencyObject. I think that I might solve this problem if I simply init all Format values manually from C# code, but I think that there should be better solutions using XAML binding expressions.

Any ideas?

  • 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-31T10:59:02+00:00Added an answer on May 31, 2026 at 10:59 am

    I should use something other ValidationStep=”RawProposedValue”, then I will be getting BindingExpression as a value parameter at my Validate method, and this BindingExpression.DataItem property contains actual data item that I am looking for.

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

Sidebar

Related Questions

I have a DataGrid, with an ItemTemplate that has an image and label. In
I have a DataGrid component that displays a few columns of data. It has
I have a page (below) that has a datagrid that lists item's returned from
We have a Flex DataGrid with 3 columns of which one of them has
I have this datagrid which has columns with a NumericStepper as an itemEditor where
I have a DataGrid that has event handlers bound to SortCommand and PageIndexChanged .
I have a wpf datagrid that has it's columns generated dynamically in code and
I have a DataGrid, which is showing some stuff. Each of the cells has
I have a datagrid that has a DataNavigateUrlFormatString that passes info on to the
I have a DataGrid that has AutoGenerateColumns=True. I'm binding that DataGrid to a collection

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.