in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

C1DateTimePicker custom template

Last post 07-01-2008 12:48 AM by duydoan. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-30-2008 1:11 PM

    C1DateTimePicker custom template

    Hi, please anyone help me to fix this template. This template generally works fine but it always closes Month Calendar popup when click Back, Forward arrow button to change month, it assumes to stay open until user change selected date. Here's the template:

    <Style x:Key="C1DateTimePicker_Default" TargetType="{x:Type c1sched:C1DateTimePicker}">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="{x:Type c1sched:C1DateTimePicker}">

    <Grid>

    <Grid.ColumnDefinitions>

    <ColumnDefinition Width="Auto" />

    <ColumnDefinition Width="Auto" />

    </Grid.ColumnDefinitions>

    <ComboBox Grid.Column="0" x:Name="PART_DatePicker"

    SelectedValue="{Binding Date, RelativeSource={RelativeSource TemplatedParent}}"

    Focusable="False" Height="21" Margin="0,0,0,0" MinWidth="105" Width="Auto"

    MaxDropDownHeight="265">

    <ComboBox.Template>

    <ControlTemplate TargetType="{x:Type ComboBox}">

    <c1sched:TextBlockBorder Name="dateBorder" Grid.Column="0"

    CornerRadius="3"

    Background="{DynamicResource EnabledBackground_Default}"

    BorderBrush="{DynamicResource EnabledBorder_Default}" Margin="0,0,0,0">

    <DockPanel Margin="0">

    <ToggleButton x:Name="arrowButton" Grid.Column="2"

    Template="{DynamicResource ComboBoxToggleButton}" Focusable="false"

    IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"

    ClickMode="Press" DockPanel.Dock="Right"/>

     

    <Popup x:Name="PART_Popup" MinWidth="160" MinHeight="120"

    StaysOpen="false" FocusManager.IsFocusScope="true"

    PlacementTarget="{Binding ElementName=dateBorder}" Focusable="False"

    AllowsTransparency="True"

    IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"

    PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" DockPanel.Dock="Right">

    <themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">

    <Border

    Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"

    BorderThickness="1"

    BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}">

    <c1sched:C1MonthCalendar x:Name="cal"

    CalendarHelper="{Binding Path=CalendarHelper, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type c1sched:C1DateTimePicker}}}"

    Date="{Binding Path=SelectedValue, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>

    </Border>

    </themes:SystemDropShadowChrome>

    </Popup>

     

    <c1sched:MethodCaller x:Name="uncheckArrowButtonMethod"

    ObjectInstance="{Binding ElementName=arrowButton}"

    MethodName="set_IsChecked" Width="0" Height="120">

    <c1sched:MethodCaller.MethodParameters0>

    <sys:Boolean>false</sys:Boolean>

    </c1sched:MethodCaller.MethodParameters0>

    </c1sched:MethodCaller>

     

    <StackPanel x:Name="dateText" Orientation="Horizontal">

    <TextBlock

    Text="{Binding Path=SelectedValue, Converter={x:Static c1sched:DateTimeToStringConverter.Default}, ConverterCulture=vi-VN, ConverterParameter=ddd, RelativeSource={RelativeSource TemplatedParent}}"/>

    <TextBox BorderThickness="0" Style="{x:Null}"

    Validation.ErrorTemplate="{DynamicResource ovalValidationTemplate}" Margin="3,0,0,0">

    <Binding Path="SelectedValue"

    RelativeSource="{RelativeSource TemplatedParent}"

    Converter="{x:Static c1sched:DateTimeToStringConverter.Default}"

    ConverterParameter="dd/MM/yy"

    NotifyOnValidationError="true"

    UpdateSourceTrigger="PropertyChanged">

    <Binding.ValidationRules>

    <c1sched:DateTimeStringValidator Format="d" />

    </Binding.ValidationRules>

    </Binding>

    </TextBox>

    </StackPanel>

    </DockPanel>

    </c1sched:TextBlockBorder>

    <ControlTemplate.Triggers>

    <Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="true">

    <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5" />

    <Setter TargetName="Shdw" Property="Color" Value="#71000000" />

    </Trigger>

    <Trigger SourceName="cal" Property="IsUserChangedDay" Value="True">

    <Setter TargetName="uncheckArrowButtonMethod" Property="Call" Value="true" />

    </Trigger>

    </ControlTemplate.Triggers>

    </ControlTemplate>

    </ComboBox.Template>

    </ComboBox>

     

    <ComboBox Grid.Column="1" x:Name="PART_TimePicker"

    Style="{StaticResource C1AllDayHoursComboStyle}" SelectedItem="{Binding Time,

    RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"

    IsEditable="true" IsReadOnly="false" MinWidth="70">

    <ComboBox.Text>

    <Binding Path="Time"

    RelativeSource="{RelativeSource TemplatedParent}"

    Mode="TwoWay"

    UpdateSourceTrigger="PropertyChanged"

    Converter="{x:Static c1sched:TimeToStringConverter.Default}"

    ConverterParameter="t"

    NotifyOnValidationError="true">

    <Binding.ValidationRules>

    <c1sched:TimeStringValidator Format="t" />

    </Binding.ValidationRules>

    </Binding>

    </ComboBox.Text>

    </ComboBox>

    </Grid>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    <Setter Property="Height" Value="24"/>

    </Style>

     

    Thanks guys

    Duy T. Doan

    Filed under:
  • 06-30-2008 4:56 PM In reply to

    Re: C1DateTimePicker custom template

    Try to remove Focusable="false" and ClickMode="Press" from the arrowButton definition: 

          <ToggleButton x:Name="arrowButton" Grid.Column="2" 
               Template="{DynamicResource ComboBoxToggleButton}"  
                IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" 
                DockPanel.Dock="Right"/>
              <!-- Focusable="false" ClickMode="Press" DockPanel.Dock="Right"/> -->

  • 07-01-2008 12:48 AM In reply to

    Re: C1DateTimePicker custom template

    working absolutely like you said. Thank you so much.

    D.

Page 1 of 1 (3 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.