1

VB で Callisto 設定フライアウトを追加するためのサンプルはありますか? CS にはいくつかのサンプルがありますが、VB モードではそれらを理解できないようです。トグル スイッチを 1 つ追加して、アプリが参照できるように保存します。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 に答える