Developing and supporting MVVM applications is easy and effective. That's why we want to create MVVM applications that follow this pattern. Sometimes the controls we use have some limitations. For example, list properties, which are read-only and do not allow us to create an appropriate binding to our view-models. It is normal for properties of list type to be read-only, because this is considered a good practice, but it becomes a problem for the MVVM pattern. In the ItemsControl this problem is solved with two properties - Items and ItemsSource. This blog post is about an example that demonstrates how to create an additional property for the SelectedDates property of the RadCalendar control.

Here is the demo application:



And the code of the main page is as follows:

<UserControl x:Class="CalendarAndViewModel.MainPage"
    d:DesignHeight="300" d:DesignWidth="400">
        <local:SampleViewModel />
    <Grid x:Name="LayoutRoot" Background="White">
            <RowDefinition Height="25" />
            <RowDefinition />
            <RowDefinition />
        <StackPanel Orientation="Horizontal" Grid.Row="0">
            <Button Content="Select many" Click="OnSelectManyClick" />
            <Button Content="Deselect all" Click="OnDeselectAllClick" />
        <telerik:RadCalendar Grid.Row="1"
                             local:CalendarExtensions.SelectedDates="{Binding SelectedDates, Mode=TwoWay}" />
        <ListBox Grid.Row="2" ItemsSource="{Binding SelectedDates}">



The details of the implementation process are not a subject of this article, so I will just share the project here. If interested, you can download it from here.

About the Author

Miroslav Nedyalkov

is a XAML enthusiast. Speaker at various local user groups and events. Miroslav is passionate about cutting edge technologies and likes to share his knowlage with others. You can follow him on Twitter at @miro_nedyalkov.


Comments are disabled in preview mode.