User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
Go Back  Xtreme Visual Basic Talk > > > User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page


Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2016, 03:28 PM
StealthRT's Avatar
StealthRT StealthRT is offline
Contributor
 
Join Date: Aug 2002
Posts: 785
Question User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page


Hey all I am trying to get my flyout box to close on my WPF Page XAML I created:
Code:
<Page x:Class="page_Keyboard"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:newRegisterProg"
      xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
      mc:Ignorable="d" 
      Background="Transparent"
      Height="335" 
      Width="1336"
      x:Name="kbMenu"
      Title="page_Keyboard">
    <Grid x:Name="theKBGrid">
        <Button x:Name="keyBoard_1" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="1036,10,220,255" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Width="80" Content="1" Tag="numpad"/>
        [more code here.......]
        <Button x:Name="keyBoard_period" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="1226,250,30,15" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Width="80" Content="." Tag="period"/>
        <!-- Start QWERTY Keys -->
        <Button x:Name="keyBoard_Q" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="23,10,1233,255" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Width="80" Content="Q" Tag="keyboard"/>
        <Button x:Name="keyBoard_W" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="116,10,1140,255" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Width="80" Content="W" Tag="keyboard"/>        
        <Button x:Name="keyBoard_blank1" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="23,249,1140,16" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Content="CLOSE" Tag="goback"/>
    </Grid>
</Page>
The Page code for just the button clicks:
Code:
Private Sub loopThruButtons(sender As Object, e As RoutedEventArgs)
    Dim theButton as Button = TryCast(sender, Button)
    Dim mw As New MainWindow()

    If theButton.caption = "CLOSE" Then
        mw.TopFlyoutCloseButtonOnClick(Nothing, Nothing)
    End If
End Sub
The Content="CLOSE" is the button I am using in order to close the said flyout. However, when it kicks off that function on the MainWindow it hits the yourMahAppFlyout.IsOpen = False but it never closes the flyout!

My MainWindow XAML:
Code:
<Controls:MetroWindow 
        x:Name="frmCRter" 
        x:Class="MainWindow"            
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:newRegisterProg"
        TextElement.FontWeight="Regular"
        TextElement.FontSize="13"
        TextOptions.TextFormattingMode="Ideal" 
        TextOptions.TextRenderingMode="Auto"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        mc:Ignorable="d" 
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        Background="{DynamicResource MaterialDesignPaper}"
        Height="768" Width="1336" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" IsWindowDraggable="False" IsTabStop="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" IsCloseButtonEnabled="False" ShowCloseButton="False" ShowDialogsOverTitleBar="False" ShowIconOnTitleBar="False" ShowMinButton="False" ShowMaxRestoreButton="False" ShowSystemMenuOnRightClick="False" ShowTitleBar="False" TitlebarHeight="0" WindowStyle="None" Title="frmCRter">    
    <Grid>
        <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="134,95,0,0" VerticalAlignment="Top" Width="75"  Style="{StaticResource AccentedSquareButtonStyle}"/>            
    </Grid>
    <Controls:MetroWindow.Flyouts>
        <Controls:FlyoutsControl x:Name="flyoutsControl">
            <Controls:Flyout AnimateOpacity="True" 
                             TitleVisibility="Collapsed" 
                             CloseButtonVisibility="Collapsed" 
                             IsModal="True" 
                             MinHeight="335"
                             Position="Bottom" 
                             Width="1336" 
                             Height="335"
                             Theme="Adapt"
                             x:Name="yourMahAppFlyout">
                <Grid>
                    <Frame x:Name="CenterFrame" 
                           VerticalAlignment="Stretch" 
                           VerticalContentAlignment="Center" 
                           HorizontalAlignment="Left" 
                           HorizontalContentAlignment="Center" 
                           Source="page_Keyboard.xaml" 
                           Background="Transparent" 
                           Width="1336" />
                </Grid>
            </Controls:Flyout>
        </Controls:FlyoutsControl>
    </Controls:MetroWindow.Flyouts>
</Controls:MetroWindow>
And the MainWindow code:
Code:
Class MainWindow
    Inherits MetroWindow       

    Private Sub ToggleFlyout(index As Integer)
        Dim flyout = TryCast(Me.Flyouts.Items(index), Flyout)
        If flyout Is Nothing Then
            Return
        End If

        flyout.IsOpen = Not flyout.IsOpen
    End Sub

    Public Sub TopFlyoutCloseButtonOnClick(sender As Object, e As RoutedEventArgs)
        yourMahAppFlyout.IsOpen = False
    End Sub
End Class
If I just add a close button to the code area and have the flyout pop up without using the Frame - using that close button works just fine to close the flyout.
Code:
<Controls:MetroWindow.Flyouts>
    <Controls:FlyoutsControl x:Name="flyoutsControl">
        <Controls:Flyout AnimateOpacity="True" 
                         TitleVisibility="Collapsed" 
                         CloseButtonVisibility="Collapsed" 
                         IsModal="True" 
                         MinHeight="335"
                         Position="Bottom" 
                         Width="1336" 
                         Height="335"
                         Theme="Adapt"
                         x:Name="yourMahAppFlyout">
            <Grid>
                <Button x:Name="CloseButton" materialDesign:ShadowAssist.ShadowDepth="Depth1" FontSize="40" FontWeight="Bold" Style="{StaticResource MaterialDesignRaisedDarkButton}" Margin="23,249,1140,16" materialDesign:RippleAssist.Feedback="AliceBlue" Height="70" Click="TopFlyoutCloseButtonOnClick" Content="Close" />
            </Grid>
        </Controls:Flyout>
    </Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
What could I be missing in order for it to close the flyout?
Reply With Quote
  #2  
Old 12-05-2016, 04:55 PM
PlausiblyDamp's Avatar
PlausiblyDampUser MAHAPPs with WPF calling function on MainWindow when on flyout Frame page PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I would assume that the problem is the bit of code
Code:
  Dim mw As New MainWindow()

    If theButton.caption = "CLOSE" Then
        mw.TopFlyoutCloseButtonOnClick(Nothing, Nothing)
    End If
In that routine you are creating a new instance of the MainWindow class and trying to close it's Flyout rather than the Flyout on the existing MainWindow instance.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply

Tags
flyout, close, button, mainwindow, code, page, dim, routedeventargs, false, yourmahappflyout.isopen, object, class, flyout.isopen, private, wpf, frame, function, xaml, toggleflyoutindex, fine, inherits, missing, closes, integer, metrowindow


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
 
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
User MAHAPPs with WPF calling function on MainWindow when on flyout Frame page
 
-->