How can I forcefully create an object declared in resources

I declare an object in XAML (under UserControl.Resources) like this:

<vm:ErrorDisplayService x:Key="EDSvc"/>

      

My object's constructor is not being called.

I can get it to work if I put a mock object like this:

<TextBlock Visibility="Collapsed" Text={StaticResource EDSvc}/>

      

but that seems like a hack to me.

Is there a cleaner way to do this?

JAB

+3
c # wpf xaml


source to share


No one has answered this question yet

See similar questions:

3
Failed to bind to DataContext

or similar:

1064
How to sort list <T> by property in object
805
How do I get a .NET application to run under administrator control?
31
How to bind background color in WPF / XAML?
3
WPF Auto vs Star grid size
2
How to bind DataGridTemplateColumn Visibility to textBlock Visibility
2
How to reference a static resource from the current resources of a component?
1
Setting up DataContext using StaticResource
0
XAML data binding not updating
0
WPF uses a converter to datatemplate created from xaml text and XamlReader by phone 8
0
combo box inside custom control disappears when styling is applied in wpf



All Articles
Loading...
X
Show
Funny
Dev
Pics