Find XAML Resource in global Theme
Hello!
What can i replace WPF code
in Noesis / Unity ?
in code behind working:
but I need to find the Style in Theme.XAML from converter for my ViewModel
I will be glad to answer
What can i replace WPF code
Code: Select all
Style style = Application.Current.FindResource("key") as Style;
in code behind working:
Code: Select all
Style style = (Style)this.FindResource("key");
I will be glad to answer
Re: Find XAML Resource in global Theme
I'm write this code:
using
And this working
This allows you to apply the style from Global XAML Theme in viewmodel, converter and etc
Why Noesis allows you to find a style not related to the new FrameworkElement - I don't know, but it works
if someone explains the mechanism, I'll be happy
Code: Select all
using Noesis;
internal static class Utilities
static FrameworkElement frameworkElement = new FrameworkElement();
internal static Style GetStyle(string key)
{
return (Style)frameworkElement.FindResource(key);
}
}
Code: Select all
Utilities.GetStyle("key");
This allows you to apply the style from Global XAML Theme in viewmodel, converter and etc
Why Noesis allows you to find a style not related to the new FrameworkElement - I don't know, but it works
if someone explains the mechanism, I'll be happy
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Find XAML Resource in global Theme
Accessing the Application.Resources is something that we should expose, I created a ticket in our bugtracker for this feature: https://www.noesisengine.com/bugs/view.php?id=1505
This is working because the default behavior of FindResource in any FrameworkElement is:Why Noesis allows you to find a style not related to the new FrameworkElement - I don't know, but it works
- First search for the resource in same element Resources
- Next search in the same element Style.Resources
- Next search in the same element Template.Resources
- Repeat the process in the logical tree upwards until the root is reached
- Finally search in the Application.Resources
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Dmirty, Google [Bot], Semrush [Bot] and 15 guests