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

Update from Version 0.13.1 to a higher one #3038

Closed
kaijauk opened this Issue Sep 5, 2017 · 10 comments

Comments

Projects
None yet
2 participants
@kaijauk

kaijauk commented Sep 5, 2017

I wanted to finally update my MahApps.Metro with the NuGet Manager for my Project. In one WPF Window I use the FlipView Control and when I update Metro I always end up with an NullPointer Exception in the FlipView class, Method: FlipViewLoaded

It does not matter if I update to version 0.14 or 1.0.0 or 1.5.0 - it always crashes.

When I exclude the FlipView it starts but every window I call with .ShowDialog() does not show up.

Did anyone experienced the same?

I use Visual Studio 2013 and got it through the NuGet Manager.

@punker76

This comment has been minimized.

Member

punker76 commented Sep 5, 2017

@kaijauk This is a big step :-D Can you provide the code and maybe a stack trace?

@kaijauk

This comment has been minimized.

kaijauk commented Sep 5, 2017

@punker76 yeah, i know :-D i totally forgot to do it the past two years so here i am haha :)

I can't provide the code of the FlipView Class because it is in the MahApps.dll, sometimes also an error in the WindowChromeWorker.cs shows up.

I have also installed AvalonDock and MVVM Light in my project.

When I want to start after the Update I first have to replace all "TextboxHelper" with "TextBoxHelper" due to the change in update 1.0.0. After that when I want to start including the Form which uses the FlipView I get the following StackTrace with the NullReferenceException:

bei MahApps.Metro.Controls.FlipView.FlipView_Loaded(Object sender, RoutedEventArgs e)
bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
bei System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
bei System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
bei MS.Internal.LoadedOrUnloadedOperation.DoWork()
bei System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
bei System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()

In Data it says: {System.Collections.ListDictionaryInternal}

@punker76

This comment has been minimized.

Member

punker76 commented Sep 5, 2017

@kaijauk this was a bug which is fixed now, so make sure you use the latest 1.5.0

@kaijauk

This comment has been minimized.

kaijauk commented Sep 5, 2017

@punker76 if I start debugging with the 1.5.0 version a dialog pops up requiring the path for the FlipView.cs. If click Cancel it asks for the WindowChromeWorker.cs

and then again I get this Exception:

bei MahApps.Metro.Controls.FlipView.FlipViewLoaded(Object sender, RoutedEventArgs e) in d:\projects\git\MahApps.Metro\src\MahApps.Metro\MahApps.Metro.Shared\Controls\FlipView.cs:Zeile 266.
bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
bei System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
bei System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
bei System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
bei MS.Internal.LoadedOrUnloadedOperation.DoWork()
bei System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
bei System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
bei System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
bei System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
bei System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
bei System.Windows.Interop.HwndTarget.OnResize()
bei System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

@punker76

This comment has been minimized.

Member

punker76 commented Sep 5, 2017

@kaijauk Are you using a custom style for this Flyout?

@kaijauk

This comment has been minimized.

kaijauk commented Sep 5, 2017

<mah:FlipView BorderThickness="0" ItemsSource="{Binding ZukuenftigeSponsionen}" Focusable="False" IsBannerEnabled="False" 
                              Template="{DynamicResource BirthdayFlipViewStyle}" x:Name="SponsionFLipView" SelectedItem="{Binding SelectedSponsionItem, Mode=TwoWay}">
                    <mah:FlipView.ItemTemplate>
                        <DataTemplate>
                            ...

and the BirthdayFlipViewStyle looks like this:


        <ControlTemplate x:Key="BirthdayFlipViewStyle" TargetType="{x:Type mah:FlipView}">
            <ControlTemplate.Resources>
                <Style x:Key="ControlButton" TargetType="{x:Type Button}">
                    <Setter Property="Height" Value="30"/>
                    <Setter Property="Cursor" Value="Hand" />
                    <Setter Property="Width" Value="50"/>
                    <Setter Property="Opacity" Value="0.4"/>
                    <Setter Property="Panel.ZIndex" Value="5"/>
                    <Setter Property="IsTabStop" Value="False"/>
                    <Setter Property="Focusable" Value="True"/>
                    <Setter Property="Background" Value="{DynamicResource WhiteBrush}"/>
                    <Setter Property="Foreground" Value="{DynamicResource TextBrush}"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border BorderBrush="{TemplateBinding Background}" CornerRadius="4" Padding="1">
                                    <Grid Background="{TemplateBinding Background}">
                                        <Label Foreground="{TemplateBinding Foreground}" FontSize="17" FontFamily="Marlett" HorizontalAlignment="Center" VerticalAlignment="Center">
                                            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentSource="Content"/>
                                        </Label>
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Opacity" Value="1"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
                <Storyboard x:Key="ShowBannerStoryboard">
                    <DoubleAnimation AccelerationRatio="1" SpeedRatio="2.5" To="30" Storyboard.TargetProperty="Height"/>
                </Storyboard>
                <Storyboard x:Key="HideBannerStoryboard">
                    <DoubleAnimation AccelerationRatio="1" SpeedRatio="2.5" To="0" Storyboard.TargetProperty="Height"/>
                </Storyboard>
                <Storyboard x:Key="HideControlStoryboard">
                    <DoubleAnimation AccelerationRatio="1" SpeedRatio="2.5" To="0" Storyboard.TargetProperty="Opacity"/>
                </Storyboard>
                <Storyboard x:Key="ShowControlStoryboard">
                    <DoubleAnimation AccelerationRatio="1" SpeedRatio="2.5" To="1" Storyboard.TargetProperty="Opacity"/>
                </Storyboard>
            </ControlTemplate.Resources>
            <Grid x:Name="root" FocusVisualStyle="{x:Null}">
                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                    <Grid>
                        <Grid x:Name="ControlGrid" Panel.ZIndex="5">
                            <Button x:Name="PART_BackButton" HorizontalAlignment="Left" Style="{DynamicResource ControlButton}" VerticalAlignment="Center">
                                <Path Data="F1M22.6563,23.75L24.6563,25.75 31.9063,32.75 25.4063,32.75 15.9063,23.75 25.4063,14.75 31.9063,14.75 24.6563,21.75 22.6563,23.75z" Fill="{DynamicResource BlackBrush}" Height="18" Canvas.Left="15.9063" Stretch="Fill" Canvas.Top="14.75" Width="16"/>
                            </Button>
                            <Button x:Name="PART_ForwardButton" HorizontalAlignment="Right" Style="{DynamicResource ControlButton}" VerticalAlignment="Center">
                                <Path Data="F1M25.1563,23.75L23.1563,21.75 15.9063,14.75 22.4063,14.75 31.9063,23.75 22.4063,32.75 15.9063,32.75 23.1563,25.75 25.1563,23.75z" Fill="{DynamicResource BlackBrush}" Height="18" Canvas.Left="15.9063" Stretch="Fill" Canvas.Top="14.75" Width="16"/>
                            </Button>
                            <Grid x:Name="PART_BannerGrid" Background="{DynamicResource BlackBrush}" Height="0" Opacity="0.85" VerticalAlignment="Bottom" Panel.ZIndex="6">
                                <Label x:Name="PART_BannerLabel" Foreground="{DynamicResource WhiteBrush}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" IsTabStop="False"/>
                            </Grid>
                        </Grid>
                        <mah:TransitioningContentControl x:Name="PART_Presenter" ContentTemplate="{TemplateBinding ItemTemplate}" Content="{TemplateBinding SelectedItem}" IsTabStop="False" Panel.ZIndex="1"/>
                    </Grid>
                </Border>
            </Grid>
        </ControlTemplate>
@punker76

This comment has been minimized.

Member

punker76 commented Sep 5, 2017

@kaijauk Just as I thought. This style (template) no longer fits to version 1.5.0. One way is that you update your style and another one is that I will look for a better handling if the inner buttons (up/down) doesn't exists.

@punker76 punker76 added this to the 1.6.0 milestone Sep 5, 2017

@punker76 punker76 added the Bug label Sep 5, 2017

@punker76 punker76 closed this in c258a59 Sep 5, 2017

@punker76

This comment has been minimized.

Member

punker76 commented Sep 5, 2017

@kaijauk This will be fixed in upcoming 1.6.0. The Flipview should now work against older styles too.

@kaijauk

This comment has been minimized.

kaijauk commented Sep 7, 2017

@punker76 thank you very much! 👍 removing the style template worked! It starts now! :)

though every window I call with .ShowDialog() does not show up except in the taskbar.
The Dialogs are all MetroWindow-Objects.

Should I change them?

@kaijauk

This comment has been minimized.

kaijauk commented Sep 7, 2017

@punker76
okay I got something:

I made all Dialogs appear transparent with a workaround and used this method:

    public Dialog()
    {
        InitializeComponent();
         this.SourceInitialized += NoMovingAllowed;
         AllowsTransparency = true;
    }

    private void NoMovingAllowed(object sender, EventArgs e)
    {
        WindowInteropHelper helper = new WindowInteropHelper(this);
        HwndSource source = HwndSource.FromHwnd(helper.Handle);
        source.AddHook(WndProc);
    }

    const int WM_SYSCOMMAND = 0x0112;
    const int SC_MOVE = 0xF010;

    private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {

        switch (msg)
        {
            case WM_SYSCOMMAND:
                int command = wParam.ToInt32() & 0xfff0;
                if (command == SC_MOVE)
                {
                    handled = true;
                }
                break;
            default:
                break;
        }
        return IntPtr.Zero;
    }

However, if I remove the "AllowsTransparency = true;" part, the dialog shows up again! :)

Is there a way to allow the Transparency of a window? Changing it in the XAML doesn't change anything...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment