diff --git a/ModernWpf.Controls/Common/SharedHelpers.cs b/ModernWpf.Controls/Common/SharedHelpers.cs index 213521f6..49266990 100644 --- a/ModernWpf.Controls/Common/SharedHelpers.cs +++ b/ModernWpf.Controls/Common/SharedHelpers.cs @@ -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); diff --git a/ModernWpf.Controls/NavigationView/NavigationView.cs b/ModernWpf.Controls/NavigationView/NavigationView.cs index 71cd54bc..55b9e497 100644 --- a/ModernWpf.Controls/NavigationView/NavigationView.cs +++ b/ModernWpf.Controls/NavigationView/NavigationView.cs @@ -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()