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:
With this statement you no longer require the constructor or InitializeComponent (and it works).
Example follows:
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>