Skip to content

Commit

Permalink
make sure NavigationView gets resource from element instead app.xaml …
Browse files Browse the repository at this point in the history
…resource dictionary (#123)

Co-authored-by: Stefan Koell <stefan.koell@royalapps.com>
  • Loading branch information
StefanKoell and StefanKoell committed Jun 25, 2020
1 parent 5dd7ba5 commit 1e4cce8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ModernWpf.Controls/Common/SharedHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public static object FindResource(string resource, ResourceDictionary resources,
return resources.Contains(boxedResource) ? resources[boxedResource] : defaultValue;
}

public static object FindResource(string resource, FrameworkElement element, object defaultValue)
{
return element.TryFindResource(resource) ?? defaultValue;
}

public static object FindInApplicationResources(string resource, object defaultValue)
{
return SharedHelpers.FindResource(resource, Application.Current.Resources, defaultValue);
Expand Down
4 changes: 2 additions & 2 deletions ModernWpf.Controls/NavigationView/NavigationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3542,12 +3542,12 @@ int GetSelectedItemIndex()

double GetPaneToggleButtonWidth()
{
return (double)(SharedHelpers.FindInApplicationResources("PaneToggleButtonWidth", c_paneToggleButtonWidth));
return (double)(SharedHelpers.FindResource("PaneToggleButtonWidth", this, (double)c_paneToggleButtonWidth));
}

double GetPaneToggleButtonHeight()
{
return (double)(SharedHelpers.FindInApplicationResources("PaneToggleButtonHeight", c_paneToggleButtonHeight));
return (double)(SharedHelpers.FindResource("PaneToggleButtonHeight", this, (double)c_paneToggleButtonHeight));
}

void UpdateTopNavigationWidthCache()
Expand Down

0 comments on commit 1e4cce8

Please sign in to comment.