mui
mui copied to clipboard
Object reference not set to an instance of an object error in application template
When I create new project from Modern UI WPF Application template I get the error in design time (it's build and run ok). How I can fix it?
VS2013
Rebuild project and reopen file in designer. This should help
Sure, I tried it many time without effect. ReSharper can't find Heading1, Heading2 etc StaticResources too. Could you check this "bug" on you PC, please?
In my case i don't use ReSharper and XAML UI Designer. I use Source Editor to code and Blend to visualization and i haven't this bug.
ps. sorry for my poor english
I have the same issue on VS 2015.
Did anyone find a solution for this issue. I am experiencing the same thing using VS2015.
Try: DynamicResource instead StaticResource
Thank you for the suggestion. Yes I tried that, actually, that was one of the first things that I tried, but still got the same results. Unfortunately, the app resource code for that isn't available to me just using the templates. Removing the style reference altogether and running the application gives you a completely blank window so I know the xaml engine can "see" the resource I just think that there are some bugs in the resource itself that cannot be resolved. :(
I just found out that the issue only happens with the XAML Designer. I am guessing it happens as the designer tried to use the resources to render the preview window (which I don't use btw).
If I open the XAML with the Source Code Text Editor as mjasin pointed before the error goes away.
Thanks mjasin, I have been hitting my head on the wall because of this.
I just moved the Style setting to the code behind. I put this line after InitializeComponent(); Style = (Style)App.Current.Resources["BlankWindow"]; Then just removed the style setting from the xaml.
I had the same problem with ModernUI extention. My solution was to edit the App.Xaml Resources:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" />
<ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Yes. It seems like it is just a designer issue for rendering the controls.