Binding SelectedAppointments

4 posts, 1 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 28 Oct 2012 Link to this post

    Hi,

    I want to access the SelectedAppoints from the viewmodel, but it seems impossible to bind this property.

    I can bind SelectedAppointment but why can i not bind SelectedAppointments?

    Is there an other way to get this collection into the viewmodel? There is no events that i seem to be able to hook into when this collection changes either.

    Best Regards,

    Peter

     

  2. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 01 Nov 2012 Link to this post

    Hi Peter,

    The SelectedItems property cannot be bound to the ViewModel's property, because it is a read-only dependency property and cannot be set. What I would suggest you is to set the ViewModel's property to the SelectedAppointments collection (the property of the ScheduleView is never changed) in the page's constructor like this:
    InitializeComponent();
    this.viewModel.ScheduleViewSelectedAppointments = this.scheduleView.SelectedAppointments;

    Hope this helps.

    All the best,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 02 Nov 2012 Link to this post

    Hi Miroslav,

    That helps me out somewhat, however it makes it difficult to base any kind of behavior on the collection. For example, if i would want to enable a button based on this collection changing or being set.

    Anyways, i was able to program arround the limitation, but i still wonder why this collection is not exposed a little easier.

    Best Regards,

    Peter
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 02 Nov 2012 Link to this post

    Hello Peter,

    One of the main reasons we decided to do so is that the default Silverlight and WPF controls are exposing their selection as a read-only property and we wanted to be consistent with these controls (like ListBox, DataGrid, TabControl, etc.).

    Another important reason is that there are too many scenarios that should be handled if the property is settable and it lets both the user of the control and the developer of the control to do mistakes which we'd like to minimize.

    Hope this makes sense to you.

    All the best,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top