Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRE in design mode with MahApps HamburgerMenu control #302

Open
canton7 opened this issue Nov 6, 2021 Discussed in #289 · 0 comments
Open

NRE in design mode with MahApps HamburgerMenu control #302

canton7 opened this issue Nov 6, 2021 Discussed in #289 · 0 comments

Comments

@canton7
Copy link
Owner

canton7 commented Nov 6, 2021

Discussed in #289

Originally posted by sm-g October 1, 2021

Object reference not set to an instance of an object.
   at Stylet.Xaml.View.<>c.<.cctor>b__10_0(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.Activate(Object item)
   at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Run(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

But everything work in runtime. Can I solve this issue?

(Hope this condensed xaml still reproduces the issue)

<UserControl x:Class="Foo"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"           
             xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:pages="clr-namespace:Foo.Pages"
             xmlns:s="https://github.com/canton7/Stylet"
             d:DesignHeight="450"
             d:DesignWidth="800"
             mc:Ignorable="d">
    <mah:HamburgerMenu 
                       Content="{Binding Pages/}"
                       ItemsSource="{Binding MenuItems}"
                       SelectedItem="{Binding MenuItems/}">

        <mah:HamburgerMenu.ContentTemplate>
            <DataTemplate DataType="{x:Type pages:PageViewModelBase}">
                        <ContentControl s:View.Model="{Binding}" />
            </DataTemplate>
        </mah:HamburgerMenu.ContentTemplate>
    </mah:HamburgerMenu>
</UserControl>
```</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant