1

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

4

1 回答 1

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”控件的示例:

<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

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

于 2013-06-09T14:48:44.547 回答