Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Application.Resources availability during Bootstrapping

$
0
0
I just encountered an Interesting behavior creating a brand new application. "The name 'InitializeComponent' does not exist in the current context" happened after I added the following to see if it would resolve my issue of not being able to access App.xaml styles from my modules:
        public App()
        {
            InitializeComponent();
        }
I found this odd as I had not encountered this problem until now - when I discovered the problem it made sense as I generally have merged dictionaries. In your App.Xaml file you have to have the following: <ResourceDictionary.MergedDictionaries/>

With this statement you no longer require the constructor or InitializeComponent (and it works).

Example follows:
<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries/>
            <Style TargetType="Button">
                <Setter Property="Command" Value="{Binding GenericCommand}"/>
                <Setter Property="CommandParameter" Value="{Binding RelativeSource={RelativeSource Self}}"/>
            </Style>            
        </ResourceDictionary>
    </Application.Resources>

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>