Proton
Proton

Reputation: 236

DatePicker wpf doesn't update the source when selecting the same date

I have grid with a column of datepickers. And i have a datepicker in the header of that column to set the date for all the columns. The problem is that when i select the date in the header date picker, it's set to all the columns, then i'm adding some new rows to the grid (which has no date by default) and trying to set the same date through the header date picker, it doesn't update anything. If i'm choosing a different date, everything is fine, and all the rows (including new ones) are getting updated.
This is my header datepicker:

<DatePicker SelectedDate="{Binding DataContext.BaseDateForAll,RelativeSource={RelativeSource AncestorType=Window},Mode=TwoWay}"

And the property for updating looks like this:

public DateTime BaseDateForAll
    {
        get
        {
            return baseDateForAll;
        }
        set
        {
            baseDateForAll = value;
            if (Settings != null)
            {
                //updating row values
            }
        }
    }

I've debugged it, i'm not getting to the basedateforall setter when i choose the same date. Is there any way to get around it?

Upvotes: 0

Views: 1009

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174309

Why would you want that event to be fired? The value didn't change and because of that, your property still should have the same value as before.
What you really should do:
Add the new rows with the date of BaseDateForAll.

Upvotes: 2

Related Questions