Примерная настройка параметров Callisto в VB

У кого-нибудь есть образец для добавления настроек Callisto в VB? В CS есть несколько сэмплов, но я не могу понять их в режиме VB. Я хочу добавить один тумблер и сохранить его для справки моего приложения. Я использую VB и XAML.

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

Это должно охватывать большую часть этого. При добавлении кода на ваши панели вы можете просто обращаться с ними как с любой другой страницей или элементом управления с точки зрения получения ввода и сохранения настроек.

Другие вопросы по тегам