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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:57:25+00:00 2026-05-22T14:57:25+00:00

Stumped : I am in the initial stages of creating a month planner control

  • 0

Stumped : I am in the initial stages of creating a month planner control that need to carry out some UI action I The control when supplying a date from the ViewModel bound in XAML. When I run the code, the ViewModel does return the value but the PropertyChangeCallBack is not firing. I have done exactly the same thing in an public class ExtendedDataGrid : DataGrid control and that work fine but it is almost like you have to do something different with UserControls. Here is the basis of my code:

public partial class DiaryMonthViewUserControl : UserControl
{
    private DateTime _topDate;


    public DiaryMonthViewUserControl()
    {
        InitializeComponent();
    }

    // Property to get the date from the ViewModel for processing. This will fire and event to set the month we want to display
    public static readonly DependencyProperty TheDateProperty = DependencyProperty.Register("TheDate", typeof(DateTime),
                      typeof(DiaryMonthViewUserControl),
                      new FrameworkPropertyMetadata(DateTime.Today, OnDatePropertyChanged, null));

    public void SetTheCurrentDate(DateTime CurrentDate)
    {
        _topDate = CurrentDate;

        // Like Outlook, whatever date we supply, I want the first top level displayed date for the month
        if (_topDate.Day > 1)
            _topDate = _topDate.AddDays(-(_topDate.Day-1)); // First day of the month

        // Get to the first Monday before the 1st of the month if not on a Monday
        while (_topDate.DayOfWeek != DayOfWeek.Monday)
            _topDate = _topDate.AddDays(-1);

        // I will set the UI here once I have solved this problem.
        MakeChangesToTheUIPlease();
    }

    private static void OnDatePropertyChanged(DependencyObject Source, DependencyPropertyChangedEventArgs e)
    {
        var control = Source as DiaryMonthViewUserControl;

        if (control != null)
            control.SetTheCurrentDate((DateTime)e.NewValue);
    }

    [Bindable(true)]
    public DateTime TheDate
    {
        get { return (DateTime)GetValue(TheDateProperty); }
        set { SetValue(TheDateProperty, value); }
    }
}

I have also tried using new PropertyChangedCallback(OnDatePropertyChanged) as a parameter and that still does not work.

My binding is as follows:

<my:DiaryMonthViewUserControl HorizontalAlignment="Left" Margin="12,12,0,0" x:Name="diaryMonthViewUserControl1" 
                              VerticalAlignment="Top" Height="325" Width="476" TheDate="{Binding Path=CurrentDate}" />

When I run the code my ViewModel breaks on the getter for CurrentDate and if I remove the CurrentDate binding then it does not. The problem is that the call back is not firing and, for the life of me, I cannot fathom why.

Any help would be much appreciated, particularly links to articles that may cover this problem.

  • 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-22T14:57:26+00:00Added an answer on May 22, 2026 at 2:57 pm

    The PropertyChanged callback only fires if the immediate property is changed, that means the whole DateTime object would need to be replaced, if properties of the DateTime object are changed the event will not be raised. This is why it works for primitive types like int.

    If you want to execute some method whenever any property of the DateTime changed you could implement a DateTime class which provides notifications. You can then execute the method whenever any of the properties change.

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

Sidebar

Related Questions

I'm completely stumped with a problem using CoreLocation. I've checked out some other questions
Stumped with this one. Found out through Google webmaster tools that a .htm page
Well I'm stumped. I'm writing an installation support add-on for Smart Install Maker that
I've been stumped with some SQL where I've got several rows of data, and
I'm stumped. I've created an upload image process that works in every browser except
I'm stumped here. I have an observable collection that holds business objects. I have
I'm very stumped here. I'm trying to take some server-side PHP and introduce some
I am stumped! I am building a form that allows the user to fill
I'm running into a problem that has me stumped and I was hoping someone
Is there a way, using a trigger or some other means, to ensure that

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.