Everything is fine till I add a resource dictionary. Then it looks like:
App.xaml:
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:MyApp.MyApp.Common">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
</ResourceDictionary.MergedDictionaries>
<local:MainMenuButtonVisibilityConverter x:Key="MainMenuButtonVisibilityConverter" /> <!-- withoot this line is fine-->
</ResourceDictionary>
</Application.Resources>
App.g.cs:
namespace MyApp {
...
public static void Main() {
MyApp.App app = new MyApp.App();
app.InitializeComponent(); // <------ here is the problem
app.Run();
}
}
MainMenuButtonVisibilityConverter:
namespace MyApp.MyApp.Common
{
public class MainMenuButtonVisibilityConverter : IValueConverter
{
...
}}
My error:
Error 2 'MyApp.MyApp.App' does not contain a definition for 'InitializeComponent' and no extension method 'InitializeComponent' accepting a first argument of type 'MyApp.MyApp.App' could be found (are you missing a using directive or an assembly reference?)
My project name: MyApp Folder with ViewModels and Common also is caled: MyApp
What am I doing incorrectly while adding resource dictionary?
App.xaml.cs
namespace MyApp.MyApp
{
public partial class App : Application
{
private Shell shell;
private MyAppMain myAppMain;
public App()
{
}
private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message, "", MessageBoxButton.OK, MessageBoxImage.Hand);
e.Handled = true;
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
base.Dispatcher.UnhandledException += new DispatcherUnhandledExceptionEventHandler(this.Dispatcher_UnhandledException);
myAppMain = new MyAppMain("");
}
}}
Have you tried to change the order of the declarations ? Converters should be declared at first in ResourceDictionary.