Using Callisto Library and SettingsFlyout !!!!


Ciao,
vediamo come utilizzare il controllo SettingFlyout messo a disposizione dalla Callisto Library per la nostra Settings Charm.

Partendo dal post precedente dove abbiamo parlato e visto come scaricare la Callisto Library ora proviamo ad utilizzarla per realizzare una
Settings Charm per le nostre Windows 8 Apps.

Qui ci mettiamo in ascolto sulla richiesta da parte dell’utente della Setting Pane:

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            SettingsPane.GetForCurrentView().CommandsRequested += OnSettingsPane_CommandsRequested;
            base.OnNavigatedTo(e);
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            SettingsPane.GetForCurrentView().CommandsRequested -= OnSettingsPane_CommandsRequested;
            base.OnNavigatedFrom(e);
        }

Nel delegato andiamo a definire la nostra SettingFlyout:

private void OnSettingsPane_CommandsRequested(SettingsPane sender,SettingsPaneCommandsRequestedEventArgs args)
{
SettingsCommand cmd = new SettingsCommand("", "", (x) =>
{
//nuova SettingsFlyout - CallistoLibrary
SettingsFlyout settings = new SettingsFlyout();

//Configurazione
settings.FlyoutWidth = Callisto.Controls.SettingsFlyout.SettingsFlyoutWidth.Wide;
settings.HeaderBrush = new SolidColorBrush(Color.FromArgb(255, 139, 69, 19));
settings.HeaderText = "

"
settings.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri(@"ms-appx:/Assets/BackgroundImage.png")) };

//Contenuto della SettingsFlyout
settings.Content = new SettingContent();

settings.IsOpen = true;
});
args.Request.ApplicationCommands.Add(cmd);
}

Molto rapidamente abbiamo configurato la nostra Settings Charm creando un nuovo SettingsCommand e definendo al suo interno una SettingsFlyout parte della Callisto Library.

In aggiunta come esempio ho creato una page di contenuto dedicata SettingContent fatta in questo modo:

<Page
x:Class=".SettingContent"
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"
mc:Ignorable="d">

<TextBlock Text="" FontSize="28" Margin="10,0,0,0" />
<TextBox x:Name="" Width="400"
HorizontalAlignment="Left" Margin="10,0,0,0" />

Ecco il risultato finale:

Settings Charm

Settings Charm

Lascia un commento