VB中的Callisto设置Flyout示例

时间:2013-06-07 12:18:56

标签: windows-8 windows-store-apps callisto

有没有人有一个在VB中添加Callisto settingsflyout的示例? CS中有几个样本,但我似乎无法在VB模式下理解它们。我想添加一个切换开关并将其保存为我的应用程序以供参考。我正在使用VB和XAML。

1 个答案:

答案 0 :(得分:1)

这是我在App.XAML.VB中使用的内容:

Private Sub addSettingsScenarioAdd()

    AddHandler SettingsPane.GetForCurrentView.CommandsRequested, AddressOf onCommandsRequested

End Sub

Private Sub onSettingsCommand(command As IUICommand)
    Dim settingsCommand As SettingsCommand = DirectCast(command, SettingsCommand)
    Dim rootFrame As Frame = Window.Current.Content
    rootFrame.Navigate(GetType(Page1))

End Sub

Private Sub onCommandsRequested(sender As SettingsPane, args As SettingsPaneCommandsRequestedEventArgs)
    Dim handler1 As New UICommandInvokedHandler(AddressOf onSettingsCommand)

    Dim about = New SettingsCommand("about", "About", Sub(handler)
                                                          Dim aboutpane = New SettingsFlyout()


                                                          aboutpane.Content = New AboutPanel()
                                                          aboutpane.IsOpen = True
                                                          aboutpane.HeaderText = "About"
                                                          aboutpane.Background = New SolidColorBrush(Colors.White)
                                                          UserSettings.Values("isAboutOpen") = "yes"
                                                      End Sub)
    args.Request.ApplicationCommands.Add(about)
End Sub

然后使用SettingsFlyout控件收集和存储设置(例如,您可以存储在App.XAML.VB中的隔离存储或设置属性中,可以从弹出控件中进行更改。

这应该让你开始(你显然还需要为弹出窗口创建控件,这只需要是页面上正确尺寸/形状的用户控件。这是我的'aboutpanel'控件的一个例子:< / p>

<UserControl
x:Class="ThisApp.AboutPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FootballHub"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="480" Width="260" ManipulationMode="None">

<StackPanel >
    <Grid Background="White" Margin="0,0,0,0" ManipulationMode="None">
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="50"/>
            <RowDefinition Height="250"/>
        </Grid.RowDefinitions>
        <TextBlock x:Name="VersionAndPublisherText" HorizontalAlignment="Left" Margin="10,0,0,0" Foreground="{StaticResource MainColour}" TextWrapping="Wrap"  VerticalAlignment="Top" Height="40" Width="240" FontSize="12" Grid.Row="1" Text="Textblock" />
        <TextBlock x:Name="SupportHeadingText" Grid.Row="2" FontFamily="Global User Interface" FontSize="14" FontWeight="Bold" Foreground="Black" Margin="10,0" Text="Textblock" VerticalAlignment="Bottom" />
        <TextBlock x:Name="SupportText" Grid.Row="3" FontFamily="Global User Interface" FontSize="12" Foreground="#FF045DF6" HorizontalAlignment="Right" Width="240" Margin="0,0,10,0" Height="50" VerticalAlignment="Top" Text="Textblock" TextWrapping="Wrap" FontStyle="Italic" />
        <TextBlock x:Name="MainHeadingText" HorizontalAlignment="Left" Margin="10,0,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Bottom" Width="240" FontWeight="Bold" FontFamily="Global User Interface" Foreground="Black" FontSize="14"/>
        <TextBlock x:Name="PrivacyHeadingText" Grid.Row="4" FontFamily="Global User Interface" FontSize="14" FontWeight="Bold" Foreground="Black" Margin="10,0" Text="Textblock" VerticalAlignment="Bottom" />
        <TextBlock x:Name="PrivacyText" Grid.Row="5" FontFamily="Global User Interface" FontSize="12" Foreground="{StaticResource MainColour}" HorizontalAlignment="Right" Width="240" Margin="0,0,10,0" Height="211" VerticalAlignment="Top" Text="Textblock" TextWrapping="Wrap" />
    </Grid>
</StackPanel>

添加按钮和选项等。

我还使用处理程序来检测我的面板何时打开/关闭,以便我可以应用设置等:

    AddHandler Me.Unloaded, AddressOf closing_AboutPanel
    AddHandler Me.Loaded, AddressOf opening_AboutPanel

这应该涵盖大部分内容。将代码添加到面板时,您可以像获取输入和存储设置一样对待它们,就像任何其他页面或控件一样。