mui icon indicating copy to clipboard operation
mui copied to clipboard

Object reference not set to an instance of an object error in application template

Open Dvornik opened this issue 9 years ago • 11 comments

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?

jc9b5

VS2013

Dvornik avatar Aug 21 '15 21:08 Dvornik

Rebuild project and reopen file in designer. This should help

mjasin avatar Aug 22 '15 06:08 mjasin

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?

Dvornik avatar Aug 22 '15 09:08 Dvornik

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.

image

ps. sorry for my poor english

mjasin avatar Aug 22 '15 10:08 mjasin

I have the same issue on VS 2015.

TheAwesomeGem avatar Sep 15 '15 06:09 TheAwesomeGem

Did anyone find a solution for this issue. I am experiencing the same thing using VS2015.

danielea68 avatar Oct 07 '15 16:10 danielea68

Try: DynamicResource instead StaticResource

macgile avatar Oct 07 '15 16:10 macgile

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. :(

danielea68 avatar Oct 07 '15 17:10 danielea68

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.

raaraya avatar Oct 27 '15 19:10 raaraya

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.

pkoelbl avatar Mar 23 '16 18:03 pkoelbl

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>

yankiShechter avatar Dec 12 '16 11:12 yankiShechter

Yes. It seems like it is just a designer issue for rendering the controls.

tapan-p avatar Jan 16 '17 01:01 tapan-p