{%Pragmatic Coding%} Tips and tricks for software developers.

2Jan/140

How to combine imported and local resources in WPF user control

Hi everyone! today I will show you how to use resources in WPF.

I have several modules in my application, and there is common module that contains general staff used in multiple modules. And I need shared resources. So here is a few steps we need to gain our goal.

Step 1. Create resource file.

Resource file we will name as "ControlStyle.xaml" that will contain ResourceDictionary with our declared style.

I think it's prety clear and You my friend familiar with styling.

Step 2. Use Resource In our custom control.

So this example also shows how to load WPF styles or other Static Resources from an external file or assembly.

And remember that the local resources have to be nested within the ResourceDictionary tag.
Happy coding!

Share on social network

Share to Facebook
Share to Google Plus
Share to LiveJournal
Share to MyWorld
Share to Odnoklassniki
Share to Yandex
Tagged as: C#, wpf, xaml Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.