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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:34:04+00:00 2026-06-05T15:34:04+00:00

I have this scenario well, i’ll let the model explain. public class ScheduleMonthlyPerDayModel {

  • 0

I have this scenario well, i’ll let the model explain.

public class ScheduleMonthlyPerDayModel 
{
    public DateTime Date { get; set; }

    public string Day 
    { 
        get
        {
            return Date.Day.ToString();
        }
    }

    ObservableCollection<AppointmentDTO> _appointments;
    public ObservableCollection<AppointmentDTO> Appointments 
    {
        get
        {
            return _appointments;
        }
        set
        {
            _appointments = value;

            if (value.Count > 0)
                NotifyOfPropertyChange(() => HasSchedule);
        }
    }

    public bool BelongsToCurrentMonth
    {
        get;
        set;
    }

    public bool HasSchedule
    {
        get
        {
            return _appointments.Count > 0 ? true : false;
        }
    }

    public ScheduleMonthlyPerDayModel()
    {
        _appointments = new ObservableCollection<AppointmentDTO>();
    }

    public void ClearCollection()
    {
        _appointments.Clear();
    }
}

public class ScheduleMonthlyPerWeekModel
{
    public ScheduleMonthlyPerDayModel Sunday{get; set;}

    public ScheduleMonthlyPerDayModel Monday{get; set;}

    public ScheduleMonthlyPerDayModel Tuesday{get; set;}

    public ScheduleMonthlyPerDayModel Wednesday{get; set;}

    public ScheduleMonthlyPerDayModel Thursday{get; set;}

    public ScheduleMonthlyPerDayModel Friday{get; set;}

    public ScheduleMonthlyPerDayModel Saturday{get; set;}
}

The bindings to xaml are working with a glimpse of the xaml like this:

headereditemscontrol itemsSource= weekcollection, where weekcollection is an object of schedulemonthlyperweekmodel.

Inside that headereditemscontrol I have templated each day for each property of the schedulemonthlyperweekmodel as follows:

<Grid.ColumnDefinitions>
    <ColumnDefinition />
    <ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"  Style="{StaticResource CalendarDates}" Text="{Binding Path=Saturday.Day}" />
<ListBox Grid.Row="1" Grid.ColumnSpan="2" Padding="0" 
         ItemsSource="{Binding Path= Saturday.Appointments}"
         ItemTemplate="{StaticResource myItemStyle}"
         Visibility="{Binding Path=Saturday.HasSchedule, Converter={StaticResource BoolToVisibilityConverter}}" />

Basically, I’m trying to achieve a monthly view with each day having a collection of appointments. My problem is that when I programmatically add items to the, for example here, saturday.appointments collection, through debug appending of items is a success and notifying the main collection(weekcollection), does not refresh the UI.

What I would like to achieve is: after I add the supposed appointment to its corresponding day/dates, the user interface will also update accordingly, but how do I do that?

Currently, the UI only updates if I change/toggle to different then back, after that the appointments are shown nicely. I would like to automate it, as it is ugly to require a user to toggle to something else then back before they can see the appointments list.

  • 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-06-05T15:34:06+00:00Added an answer on June 5, 2026 at 3:34 pm

    The problem with your Visibility is that it’s binding to a readonly property which calculates a value on get. Therefore, there is no way for it to notify that it has changed.

    Your HasSchedule property needs to know when the Appointment property changes. The setter for the Appointment property only knows when the entire list changes. In your case you need to know when the contents of the list changes.

    ObservableCollection has an event which tells you when the contents of the list changes, called CollectionChanged. You should do the following to notify that your HasSchedule property has changed using this event:

    ObservableCollection<AppointmentDTO> _appointments;
    public ObservableCollection<AppointmentDTO> Appointments
    {
        get
        {
            return _appointments;
        }
        set
        {
            if (_appointments != value)
            {
                if (_appointments != null)
                    _appointments.CollectionChanged -= Appointments_CollectionChanged;
    
                _appointments = value;
    
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("HasSchedule"));
    
                if (_appointments != null)
                    _appointments.CollectionChanged += Appointments_CollectionChanged;
            }
        }
    }
    
    void Appointments_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs("HasSchedule"));
    }
    

    This is assuming, as you have said, you have implemented INotifyPropertyChanged in your ViewModel. In this case, every time your collection changes in some way, it notifies that the HasSchedule property has changed. The binding will refresh the value and update the visibility if it has changed.

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

Sidebar

Related Questions

Lets say I have a set of model classes like this: public class Person
In this scenario, I have 2 or more models: class Store(models.Model): name = models.CharField(max_length
Well this is weird let me describe the scenario I have this mailer define
Please Consider this scenario: We have a base class called clsMain : class clsMain
Well I would reproduce in a html page this scenario. I have a div
Let's say you have this scenario:a simple blog home-page that loads both static content
I have this scenario, which I think must be pretty common: class Parameter {
I have this scenario. I want group on Country and Category. A store can
I have this scenario where I would like to redirect my domains using the
Imagine this scenario: You have a desktop and a laptop. The desktop has a

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.