Приведенный ниже код работал нормально в .Net 3.5, но в .Net 4.0 время появляется в текстовом поле календаря после выделения. когда фокус находится на текстовом поле календаря,не приходит.только после того, как появится время вывода, как показано на рисунке.Я не хочу, чтобы время было частью этого.
Используемый код выглядит следующим образом:
<jkdp:XamDateTimeEditor Grid.Row="1"
Grid.Column="1"
KeyboardNavigation.TabIndex="1"
InvalidValueBehavior="RetainValue"
gcb:CommandBehavior.Event="LostFocus"
gcb:CommandBehavior.Command="{Binding EndDateChangedCommand}"
Style="{DynamicResource XamDateTimeEditor.SimpleStyle}"
Text="{Binding EndDate, Mode=TwoWay, NotifyOnSourceUpdated=true}" >
<Style x:Key="XamDateTimeEditor.SimpleStyle"
TargetType="{x:Type igdEd:XamDateTimeEditor}"
BasedOn="{StaticResource XamDateTimeEditor.DefaultFromStyle}">
<Setter Property="Height"
Value="22" />
<Setter Property="Width"
Value="150" />
<Setter Property="Margin"
Value="10,0,10,0" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="ContextMenu"
Value="{StaticResource CutCopyPasteEditorStyle}" />
<Setter Property="vw:InputBindingBehaviour.EnableErrorToolTip"
Value="True" />
<Setter Property="Focusable"
Value="False"></Setter>
<Setter Property="KeyboardNavigation.IsTabStop"
Value="False"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Focusable="False"
KeyboardNavigation.IsTabStop="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Name="PART_TextBox"
Grid.Column="0"
VerticalAlignment="Center"
Focusable="True"
KeyboardNavigation.IsTabStop="True"
Margin="0,0,2,0"
Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"
ContextMenu="{Binding Path=ContextMenu, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<TextBlock Name="PART_TextBlock"
Grid.Column="0"
Focusable="False"
KeyboardNavigation.IsTabStop="False"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="3,0,2,0"
Text="{Binding Path=NullText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"
Visibility="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NullConverter}, ConverterParameter=Visibility}" />
<ToggleButton Grid.Column="1"
Focusable="False"
KeyboardNavigation.IsTabStop="False"
MinWidth="{Binding Path=ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
<Image Source="Calendar.bmp"
Focusable="False"
KeyboardNavigation.IsTabStop="False"
Margin="2" />
</ToggleButton>
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource NullConverter}}"
Value="True">
<Setter TargetName="PART_TextBox"
Property="Visibility"
Value="Collapsed" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="EditTemplate">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igdEd:XamDateTimeEditor}">
<Grid Focusable="False"
KeyboardNavigation.IsTabStop="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<igdEd:XamDateTimeEditor x:Name="PART_DateTimeEditor"
BorderThickness="0"
Background="Transparent"
Focusable="False"
KeyboardNavigation.IsTabStop="False"
Grid.ColumnSpan="2"
Theme="{Binding Path=Theme, Mode=OneTime, RelativeSource={RelativeSource TemplatedParent}}"
NullText="{Binding Path=NullText, Mode=OneTime, RelativeSource={RelativeSource TemplatedParent}}"
DataMode="{Binding Path=DataMode, Mode=OneTime, RelativeSource={RelativeSource TemplatedParent}}"
InvalidValueBehavior="{Binding Path=InvalidValueBehavior, Mode=OneTime, RelativeSource={RelativeSource TemplatedParent}}"
IsDropDownOpen="{Binding Path=IsChecked, ElementName=PART_ToggleButton, Mode=TwoWay}"
Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"
Value="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource TemplatedParent}}"
ValueConstraint="{Binding Path=ValueConstraint, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
ContextMenu="{Binding Path=ContextMenu, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<vw:CommitTextBox x:Name="PART_FocusSite"
Grid.Column="0"
Focusable="True"
KeyboardNavigation.IsTabStop="True"
MaxLength="10"
Margin="0,0,2,0"
Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=LostFocus, Converter={StaticResource DateTimeConverter}, ConverterParameter=DateFromStyle, RelativeSource={RelativeSource TemplatedParent}}"
ContextMenu="{Binding Path=ContextMenu, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource TextBox.NormalStyle}"/>
<ToggleButton x:Name="PART_ToggleButton"
Grid.Column="1"
Focusable="False"
KeyboardNavigation.IsTabStop="False"
MinWidth="{Binding Path=ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
<ToggleButton.Content>
<Image Focusable="False"
KeyboardNavigation.IsTabStop="False"
Source="Calendar.bmp"
Margin="2" />
</ToggleButton.Content>
</ToggleButton>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>