This project has moved and is read-only. For the latest updates, please go here.

DateTimePicker DisplayMode

Feb 5, 2013 at 5:02 PM

I would like to suggest a change for the DateTimePicker. I would like the Calendar's DisplayMode property to be added to the control.

My suggestion for this is to add a dependency property, DisplayMode. Adding the functionality to the style seems to have problems. I was able to get it to work correctly by changing Popup_Opened. I was seeing performance issues still with using a binding, so I just set the DisplayMode directly. Hopefully this catches most use cases, since it is set each time the popup is opened.
    private void Popup_Opened( object sender, EventArgs e )
        if (_calendar != null)
            _calendar.DisplayMode = DisplayMode;
Feb 5, 2013 at 5:04 PM
Also, here is a change for the sample, Samples.Modules.DateTime.Views.HomeView, for testing.
      <GroupBox Header="Features" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" >
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <ColumnDefinition Width="Auto"/>
               <ColumnDefinition Width="Auto"/>
               <ColumnDefinition Width="Auto"/>
               <ColumnDefinition Width="Auto"/>

            <TextBlock Text="Format:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />
            <ComboBox x:Name="_format" Grid.Row="0" Grid.Column="1" SelectedIndex="1" ItemsSource="{Binding Source={StaticResource enumDateFormatData}}" Width="200" Margin="5,5,25,5"/>
            <TextBlock Text="FormatString:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" />
            <TextBox x:Name="_formatString" Grid.Row="1" Grid.Column="1" Text="yy MMM dd" Width="200" Margin="5,5,25,5"/>
            <TextBlock Text="Watermark:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"/>
            <TextBox x:Name="_watermark" Grid.Row="2" Grid.Column="1" Text="Enter Text" Width="200" VerticalAlignment="Center" Margin="5,5,25,5"/>
            <TextBlock Text="DisplayMode:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"/>
            <ComboBox x:Name="_displayMode" Grid.Row="3" Grid.Column="1" SelectedIndex="0" ItemsSource="{Binding Source={StaticResource enumCalendarMode}}" Width="200" Margin="5,5,25,5"/>

            <TextBlock Text="TimeFormat:" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" />
            <ComboBox x:Name="_timeFormat" Grid.Row="0" Grid.Column="3" SelectedIndex="1" ItemsSource="{Binding Source={StaticResource enumTimeFormatData}}" Width="200" Margin="5"/>
            <TextBlock Text="Time FormatString:" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" />
            <TextBox x:Name="_timeFormatString" Grid.Row="1" Grid.Column="3" Text="H:mm" Width="200" Margin="5"/>            
            <TextBlock Text="TimeWatermark:" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center"/>
            <TextBox x:Name="_timeWatermark" Grid.Row="2" Grid.Column="3" Text="Enter Text" Width="200" VerticalAlignment="Center" Margin="5"/>

      <StackPanel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left">
            <TextBlock Text="DateTimePicker Usage: " Margin="0,10,0,0" Style="{StaticResource Header}" />
            <xctk:DateTimePicker x:Name="_datetimePicker"
                                 DisplayMode="{Binding Source={x:Reference _displayMode}, Path=SelectedItem}"
                                 Format="{Binding Source={x:Reference _format}, Path=SelectedItem}"
                                 FormatString="{Binding Text, ElementName=_formatString}"
                                 Watermark="{Binding  Source={x:Reference _watermark}, Path=Text}"
                                 TimeFormat="{Binding Source={x:Reference _timeFormat}, Path=SelectedItem}"
                                 TimeFormatString="{Binding Text, ElementName=_timeFormatString}"
                                 TimeWatermark="{Binding  Source={x:Reference _timeWatermark}, Path=Text}"/>
Feb 5, 2013 at 6:17 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.