Skip to content

Commit

Permalink
Fix CalendarViewStyle and Clock Border Background
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Dec 22, 2024
1 parent d2fd0d3 commit 0a467ce
Show file tree
Hide file tree
Showing 4 changed files with 6,596 additions and 10,145 deletions.
34 changes: 29 additions & 5 deletions dev/DevWinUI.Controls/Controls/Date/CalendarViewAttach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,24 @@ private static void OnShowBorderChanged(DependencyObject d, DependencyPropertyCh
{
FrameworkElement headerBorder = DependencyObjectEx.FindDescendant(calendarView, "PART_HeaderBorder");
FrameworkElement topBorder = DependencyObjectEx.FindDescendant(calendarView, "PART_TopBorder");
var headerButton = DependencyObjectEx.FindDescendant(calendarView, "HeaderButton") as Button;
var nextButton = DependencyObjectEx.FindDescendant(calendarView, "NextButton") as Button;
var previousButton = DependencyObjectEx.FindDescendant(calendarView, "PreviousButton") as Button;

var value = (bool)e.NewValue;
var showBorder = (bool)e.NewValue;
calendarView.Loaded -= CalendarView_Loaded;
calendarView.Loaded += CalendarView_Loaded;


void CalendarView_Loaded(object sender, RoutedEventArgs e)
{
if (headerBorder == null && topBorder == null)
if (headerBorder == null || topBorder == null || headerButton == null || nextButton == null || previousButton == null)
{
headerBorder = DependencyObjectEx.FindDescendant(calendarView, "PART_HeaderBorder");
topBorder = DependencyObjectEx.FindDescendant(calendarView, "PART_TopBorder");
headerButton = DependencyObjectEx.FindDescendant(calendarView, "HeaderButton") as Button;
nextButton = DependencyObjectEx.FindDescendant(calendarView, "NextButton") as Button;
previousButton = DependencyObjectEx.FindDescendant(calendarView, "PreviousButton") as Button;

UpdateBorders();
}
}
Expand All @@ -40,11 +46,11 @@ void UpdateBorders()
{
if (headerBorder != null)
{
headerBorder.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
headerBorder.Visibility = showBorder ? Visibility.Visible : Visibility.Collapsed;
}
if (topBorder != null)
{
if (value)
if (showBorder)
{
topBorder.Height = 0;
}
Expand All @@ -53,6 +59,24 @@ void UpdateBorders()
topBorder.Height = 1;
}
}

if (headerButton == null || nextButton == null || previousButton == null)
{
return;
}

if (showBorder)
{
headerButton.Style = Application.Current.Resources["AccentHeaderNavigationButtonStyle"] as Style;
nextButton.Style = Application.Current.Resources["AccentNavigationButtonStyle"] as Style;
previousButton.Style = Application.Current.Resources["AccentNavigationButtonStyle"] as Style;
}
else
{
headerButton.Style = Application.Current.Resources["HeaderNavigationButtonStyle"] as Style;
nextButton.Style = Application.Current.Resources["NavigationButtonStyle"] as Style;
previousButton.Style = Application.Current.Resources["NavigationButtonStyle"] as Style;
}
}
UpdateBorders();
}
Expand Down
Loading

0 comments on commit 0a467ce

Please sign in to comment.