Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SettingsExample
- {
- public sealed partial class SimpleSettingsNarrow : UserControl
- {
- public SimpleSettingsNarrow()
- {
- this.InitializeComponent();
- DataContext = new TestViewModel("My Toggle Switch");
- }
- private void MySettingsBackClicked(object sender, RoutedEventArgs e)
- {
- if (this.Parent.GetType() == typeof(Popup))
- {
- ((Popup)this.Parent).IsOpen = false;
- }
- SettingsPane.Show();
- }
- }
- public class TestViewModel : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- private string _toggleSwitchText;
- public TestViewModel(string text)
- {
- ToggleSwitchText = text;
- }
- public string ToggleSwitchText
- {
- get { return _toggleSwitchText; }
- set
- {
- if (value != _toggleSwitchText)
- {
- _toggleSwitchText = value;
- NotifyPropertyChanged();
- }
- }
- }
- private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
- {
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
- }
- <UserControl
- x:Class="SettingsExample.SimpleSettingsNarrow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="using:SettingsExample"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
- d:DesignHeight="768"
- d:DesignWidth="346">
- <UserControl.Resources>
- ...
- </UserControl.Resources>
- <Border BorderBrush="Black" BorderThickness="1,0,0,0">
- <Grid Background="White" VerticalAlignment="Stretch">
- <!-- Root grid definition -->
- <Grid.RowDefinitions>
- <RowDefinition Height="80" />
- <RowDefinition Height="*" />
- </Grid.RowDefinitions>
- <Grid Background="Orange" Grid.Row="0">
- <Grid Margin="40,32,17,13">
- <Grid.Transitions>
- <TransitionCollection>
- <EntranceThemeTransition FromHorizontalOffset="50" />
- </TransitionCollection>
- </Grid.Transitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="30" />
- <ColumnDefinition Width="*" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
- <Button Click="MySettingsBackClicked" Margin="0,3,0,0" Grid.Column="0" Style="{StaticResource SettingsBackButtonStyle}" HorizontalAlignment="Left" />
- <TextBlock Margin="10,0,0,0" Grid.Column="1" FontFamily="Segoe UI" FontWeight="SemiLight" FontSize="24.6667" Text="Sound Options" HorizontalAlignment="Left" />
- <Image Source="Assets/SmallLogo.png" HorizontalAlignment="Right" Grid.Column="2" Margin="0,0,6,0" />
- </Grid>
- </Grid>
- <Grid Grid.Row="1" Margin="40,24,23,0" VerticalAlignment="Top">
- <Grid.Transitions>
- <TransitionCollection>
- <EntranceThemeTransition FromHorizontalOffset="120" />
- </TransitionCollection>
- </Grid.Transitions>
- <ToggleSwitch Header="{Binding ToggleSwitchText}" />
- </Grid>
- </Grid>
- </Border>
- </UserControl>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement