C#, WPF, vb.Net, vba, SQL Server, Access Programmierer, Excel, ASP Core MVC Webforms Telefon: 07022/9319004 freib. Software Entwickler   Kontakt
#

UWP: Frame to Empty Content

 

Ich möchte in meiner UWP Anwendung die seitliche Navigationsleiste so ausführen, dass im Hauptteile der sogenannte Content bei Bedarf geladen wird und dann aber im geschlossenen Zustand bei Bedarf verschwindet.

 

Diese Funktion kann ich nur ausführen, indem ich eine Empty Page in den Content lade

ContentFrame.Navigate(typeof(PageEmpty));

 

 

NavigationView Content

 

Den Content Frame bekommt man nur leer, wenn man ihn mit einer Leeren Seite füllt

 

 

Man kann es nur dadurch Constistent erreichen, indem man eine leere Seite erstellt und diese in den Content lädt

 

Beispiel Code in C#

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.Runtime.InteropServices.WindowsRuntime;

using Windows.Foundation;

using Windows.Foundation.Collections;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

using Windows.UI.Xaml.Controls.Primitives;

using Windows.UI.Xaml.Data;

using Windows.UI.Xaml.Input;

using Windows.UI.Xaml.Media;

using Windows.UI.Xaml.Navigation;

 

using demo_NavBar.Pages;

 

 

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

 

namespace demo_NavBar

{

    /// <summary>

    /// An empty page that can be used on its own or navigated to within a Frame.

    /// </summary>

    public sealed partial class MainPage : Page

    {

        public MainPage()

        {

            this.InitializeComponent();

        }

 

        private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)

        {

 

        }

 

        private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)

        {

            if (args.IsSettingsInvoked)

            {

                ContentFrame.Navigate(typeof(PageSettings));

            }

            else

            {

                switch (args.InvokedItem)

                {

                    case "Home":

                        ContentFrame.Navigate(typeof(PageHome ));

                        break;

                    case "Page1":

                        ContentFrame.Navigate(typeof(Page1));

                        break;

                    case "Page2":

                        ContentFrame.Navigate(typeof(Page2));

                        break;

                    case "Page3":

                        ContentFrame.Navigate(typeof(Page3));

                        break;

 

                    case "Nav Min/Max":

                        if (NavView.IsPaneOpen)

 

                        {

                            NavView.IsPaneOpen = false;

                        }

                        else

                        {

                            NavView.IsPaneOpen = true;

                        }

                        break;

                    case "Content on/off":

                        if(ContentFrame.Visibility == Visibility.Collapsed)

                        { ContentFrame.Visibility = Visibility.Visible ; }

                        else

                        { ContentFrame.Visibility = Visibility.Collapsed; }

                        

                        break;

                    case "Nav0":

                        //ContentFrame.Navigate(typeof(DBNull ));*error

                        //UnloadObject(ContentFrame); //no

                        //ContentFrame.Content=null; //*Error

                        //ContentFrame.ClearValue();

                        ContentFrame.Navigate(typeof(PageEmpty));

                        break;

 

                }

            }

        }

    }

}

 

 

 

Der XAML Code der Hauptseite

<Page

    x:Class="demo_NavBar.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:local="using:demo_NavBar"

    xmlns:local_Pages="using:demo_NavBar.Pages"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d">

 

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <NavigationView x:Name="NavView"

                    ItemInvoked="NavView_ItemInvoked"

                    SelectionChanged="NavView_SelectionChanged"

                    >

 

            <NavigationView.MenuItems>

                <NavigationViewItem Content="Home" Tag="home">

                    <NavigationViewItem.Icon>

                        <FontIcon Glyph="&#xE10F;"/>

                    </NavigationViewItem.Icon>

                </NavigationViewItem>

                <NavigationViewItemSeparator/>

                <NavigationViewItemHeader Content="Main pages"/>

                <NavigationViewItem Icon="AllApps" Content="Page1" Tag="page1"/>

                <NavigationViewItem Icon="Video" Content="Page2" Tag="page2"/>

                <NavigationViewItem Icon="Audio" Content="Page3" Tag="page3"/>

                <NavigationViewItemSeparator/>

                <NavigationViewItemHeader Content="Nav View"/>

                <NavigationViewItem Icon="AllApps" Content="Nav Min/Max" Tag="NavInOut"/>

                <NavigationViewItem Icon="AllApps" Content="Content on/off" Tag="ContentOff"/>

                <NavigationViewItem Icon="AllApps" Content="Nav0" Tag="ContentNav0"/>

            </NavigationView.MenuItems>

 

 

            <Frame x:Name="ContentFrame" Margin="24">

                <Frame.ContentTransitions>

                    <TransitionCollection>

                        <NavigationThemeTransition/>

                    </TransitionCollection>

                </Frame.ContentTransitions>

            </Frame>

 

        </NavigationView>

    </Grid>

</Page>

 

 

 

UWP Universal Windows Platform

Micorosft C# Xaml Controls

Mobile
»
UWP: Frame to Empty Content

.

Jobs, Projekte, Angebote für Freiberufler, Selbstständig an Raimund.Popp@Microsoft-Programmierer.de