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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:45:12+00:00 2026-05-20T15:45:12+00:00

I will start by saying that I am completely new to WPF. But, I

  • 0

I will start by saying that I am completely new to WPF. But, I do have 20 years Development experience and about 5 years of C# webform experience.

I am trying to diagnose a WPF application that uses a DataGrid control.

I am going to try to describe a scenario that is happening in this applicaiton..

Here are the steps that produce the “error”. I am trying to figure out what is going on:

The user adds a row to the DataGrid table.
The user changes the first column (Qty) to 1.
The user tabs across the columns.
Once the cursor passes the “Discount Pct” column and enters the next column.
At this momemt, the “Discount Pct” cell becomes outlined in Red.
No other cells can be edited until the “Discount Pct” column has been “fixed”.
The funny thing is, you can clear the cell and type the same data and the red goes away.

I thought maybe this was because the field is a “percentage” field (when you type .10, it becomes “10 %” when you leave the cell), but the same thing is happening with another (plain text/varchar) column.

Other weird things I have noticed:

If the user doesn’t enter anything in the Qty cell, but just tabs straight through all the columns, to the end, none of the cells turn red.

If the user clicks (instead of tab) on the Discount Pct cell (whether a Qty is entered or NOT), then leaves that cell (with a click or tab), the cell DOESN’T turn red.

Any ideas what is happening here? I suppose there is some type of Cell Validation failing, but why only under these specific circumstances?

How would you diagnose this? Can I display the validation error somehow (I am sure there must be a handler I can tie in to), maybe that will tell me something.

Thoughts? Ideas?

Adding code per requests:

        <DataGrid x:Name="myDataGrid" 
              ItemsSource="{Binding}" 
              CanUserAddRows="False" 
              CanUserDeleteRows="True" 
              CanUserResizeRows="False"
              SelectionUnit="CellOrRowHeader" 
              ColumnHeaderStyle="{StaticResource lclDataGridColumnHeaders}"
              RowHeaderStyle="{StaticResource lclDataGridRowHeaders}" 
              CellStyle="{StaticResource lclDataGridCellStyle}"
              HorizontalGridLinesBrush="LightBlue" 
              VerticalGridLinesBrush="LightBlue" 
              AutoGeneratingColumn="DataGrid_AutoGeneratingColumn" 
              Loaded="DataGrid_Loaded" 
              LoadingRow="DataGrid_LoadingRow"
              CurrentCellChanged="DataGrid_CurrentCellChanged"
              CellEditEnding="DataGrid_CellEditEnding">
    </DataGrid>

I figured out how to apply a Style to the “EditCell” and ued the following (from another site):

        <Style x:Key="lclDataGridCellEditStyle" TargetType="{x:Type TextBox}">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                        Value="{Binding RelativeSource={RelativeSource Self},
                                Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

Then, I assigned that to the EditingElementStyle on the datagrid (in code behind).

The Validation error generated (confirms my suspicions) is: “Value ’10 %’ could not be converted”.

This makes sense, because it is wanting the user to enter “.10” or somethinig similar (a float/double/decimal/etc)…without the “%” (treating the entry as char/text).

The issue is, this row is “imported” (copied from another table) into the DataGrid and therefore, the field is already populated. So, how can I get the DataGrid to just accept the “display value” (throwing around terms and guessing here) for the “Edit Value”?

And, why only when you Change the Qty Cell and then tab through it, does this Validation error occur?

More on the other field later…once I “solve” this one, I suspect the solution will be similar…

I can give more code, but there is alot. I am trying to just give what is necessary. If I can post an of the other code (such as AutoGeneratingColumn, which is very basic), let me know!

New information… I am guessing the reason the red box shows up after the Qty is changed, is because that triggers a row change, which does a validation. And, to fix the percentage scenario I described above, it looks like I will need to implement a “converter” as described here: http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx

Another Update….

This worked. I added the Converter to the Percentage field and now all is good for that one.

The other field that is giving me problems is an “integer” column that allows nulls. When the record is imported, that column is null, but evidently the DataGridTextColumn wants ints to NOT be null. Is there a property I can set to allow nulls? Or, do I simply need to do another converter to convert between..um… null (string) and int?? lol

Shayne

  • 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-20T15:45:12+00:00Added an answer on May 20, 2026 at 3:45 pm

    You might be able to have a column that is of type int? which would allow for nulls.

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

Sidebar

Related Questions

I will start by saying that I am completely new to WPF. I am
Ok, so I will start by saying that I am new to all this
Let me start off by saying that I am very new to WPF and
Ok I will start by saying I'm fairly new to programing android applications. That
I want to start off by saying that I have almost no experience with
I will start by saying that I don't think what I want can be
I have an asp.net page that calls a dll that will start a long
We have an ASP.Net MVC project that will start with a single web server
Let me start by saying that I have been reading the drag'n drop tutorial
I will start by saying that I am a college student with little c++

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.