Merge pull request #295 from yangjieshao/main

修复 DatePicker 2处问题
This commit is contained in:
Dong Bin
2024-07-18 21:06:07 +08:00
committed by GitHub
6 changed files with 12 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
<StackPanel Margin="20" HorizontalAlignment="Left"> <StackPanel Margin="20" HorizontalAlignment="Left">
<u:CalendarView DateSelected="CalendarView_OnOnDateSelected" DatePreviewed="CalendarView_OnOnDatePreviewed"/> <u:CalendarView DateSelected="CalendarView_OnOnDateSelected" DatePreviewed="CalendarView_OnOnDatePreviewed"/>
<TextBlock Text="{Binding #singlePicker.SelectedDate}" ></TextBlock> <TextBlock Text="{Binding #singlePicker.SelectedDate}" ></TextBlock>
<u:DatePicker Name="singlePicker" Width="200" /> <u:DatePicker Name="singlePicker" Width="200" />
<u:DateRangePicker Width="300" DisplayFormat="yyyyMMdd" /> <u:DateRangePicker Width="300" DisplayFormat="yyyyMMdd" />
</StackPanel> </StackPanel>
</UserControl> </UserControl>

View File

@@ -42,6 +42,7 @@
BorderBrush="Transparent" BorderBrush="Transparent"
BorderThickness="0" BorderThickness="0"
CornerRadius="{TemplateBinding CornerRadius}" CornerRadius="{TemplateBinding CornerRadius}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
InnerLeftContent="{TemplateBinding InnerLeftContent}" InnerLeftContent="{TemplateBinding InnerLeftContent}"
InnerRightContent="{TemplateBinding InnerRightContent}" InnerRightContent="{TemplateBinding InnerRightContent}"
@@ -76,12 +77,13 @@
Padding="8" Padding="8"
Background="{DynamicResource ComboBoxPopupBackground}" Background="{DynamicResource ComboBoxPopupBackground}"
BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}" BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}"
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}" BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}"
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
CornerRadius="{DynamicResource CalendarCornerRadius}"> CornerRadius="{DynamicResource CalendarCornerRadius}">
<u:CalendarView <u:CalendarView
Name="PART_Calendar" Name="PART_Calendar"
BorderThickness="0" BorderThickness="0"
FontSize="{DynamicResource DefaultFontSize}"
CornerRadius="{Binding $parent[Border].CornerRadius}" CornerRadius="{Binding $parent[Border].CornerRadius}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" /> IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" />

View File

@@ -35,6 +35,7 @@
Background="Transparent" Background="Transparent"
BorderThickness="1" BorderThickness="1"
CornerRadius="3 0 0 3" CornerRadius="3 0 0 3"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
InnerLeftContent="{TemplateBinding InnerLeftContent}" InnerLeftContent="{TemplateBinding InnerLeftContent}"
IsReadOnly="{TemplateBinding IsReadonly}" /> IsReadOnly="{TemplateBinding IsReadonly}" />
@@ -50,6 +51,7 @@
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
Background="Transparent" Background="Transparent"
CornerRadius="0" CornerRadius="0"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
InnerRightContent="{TemplateBinding InnerRightContent}" InnerRightContent="{TemplateBinding InnerRightContent}"
IsReadOnly="{TemplateBinding IsReadonly}" /> IsReadOnly="{TemplateBinding IsReadonly}" />
@@ -117,6 +119,7 @@
Grid.Column="0" Grid.Column="0"
Margin="8" Margin="8"
BorderThickness="0" BorderThickness="0"
FontSize="{DynamicResource DefaultFontSize}"
CornerRadius="{Binding $parent[Border].CornerRadius}" CornerRadius="{Binding $parent[Border].CornerRadius}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" /> IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" />
@@ -125,6 +128,7 @@
Grid.Column="1" Grid.Column="1"
Margin="8" Margin="8"
BorderThickness="0" BorderThickness="0"
FontSize="{DynamicResource DefaultFontSize}"
CornerRadius="{Binding $parent[Border].CornerRadius}" CornerRadius="{Binding $parent[Border].CornerRadius}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" /> IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" />

View File

@@ -165,8 +165,8 @@ public class CalendarDayButton : ContentControl
public event EventHandler<CalendarDayButtonEventArgs> DatePreviewed public event EventHandler<CalendarDayButtonEventArgs> DatePreviewed
{ {
add => AddHandler(DateSelectedEvent, value); add => AddHandler(DatePreviewedEvent, value);
remove => RemoveHandler(DateSelectedEvent, value); remove => RemoveHandler(DatePreviewedEvent, value);
} }
protected override void OnPointerReleased(PointerReleasedEventArgs e) protected override void OnPointerReleased(PointerReleasedEventArgs e)

View File

@@ -82,7 +82,7 @@ public class DatePicker: DatePickerBase, IClearControl
_textBox = e.NameScope.Find<TextBox>(PART_TextBox); _textBox = e.NameScope.Find<TextBox>(PART_TextBox);
_calendar = e.NameScope.Find<CalendarView>(PART_Calendar); _calendar = e.NameScope.Find<CalendarView>(PART_Calendar);
Button.ClickEvent.AddHandler(OnButtonClick, RoutingStrategies.Tunnel, true, _button); Button.ClickEvent.AddHandler(OnButtonClick, RoutingStrategies.Bubble, true, _button);
GotFocusEvent.AddHandler(OnTextBoxGetFocus, _textBox); GotFocusEvent.AddHandler(OnTextBoxGetFocus, _textBox);
TextBox.TextChangedEvent.AddHandler(OnTextChanged, _textBox); TextBox.TextChangedEvent.AddHandler(OnTextChanged, _textBox);
PointerPressedEvent.AddHandler(OnTextBoxPointerPressed, RoutingStrategies.Tunnel, false, _textBox); PointerPressedEvent.AddHandler(OnTextBoxPointerPressed, RoutingStrategies.Tunnel, false, _textBox);

View File

@@ -128,7 +128,7 @@ public class DateRangePicker : DatePickerBase
_startTextBox = e.NameScope.Find<TextBox>(PART_StartTextBox); _startTextBox = e.NameScope.Find<TextBox>(PART_StartTextBox);
_endTextBox = e.NameScope.Find<TextBox>(PART_EndTextBox); _endTextBox = e.NameScope.Find<TextBox>(PART_EndTextBox);
Button.ClickEvent.AddHandler(OnButtonClick, RoutingStrategies.Tunnel, true, _button); Button.ClickEvent.AddHandler(OnButtonClick, RoutingStrategies.Bubble, true, _button);
GotFocusEvent.AddHandler(OnTextBoxGetFocus, _startTextBox, _endTextBox); GotFocusEvent.AddHandler(OnTextBoxGetFocus, _startTextBox, _endTextBox);
TextBox.TextChangedEvent.AddHandler(OnTextChanged, _startTextBox, _endTextBox); TextBox.TextChangedEvent.AddHandler(OnTextChanged, _startTextBox, _endTextBox);
PointerPressedEvent.AddHandler(OnTextBoxPointerPressed, RoutingStrategies.Tunnel, false, _startTextBox, _endTextBox); PointerPressedEvent.AddHandler(OnTextBoxPointerPressed, RoutingStrategies.Tunnel, false, _startTextBox, _endTextBox);