Advertisement
Guest User

Untitled

a guest
Apr 25th, 2012
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.84 KB | None | 0 0
  1. namespace SettingsExample
  2. {
  3. public sealed partial class SimpleSettingsNarrow : UserControl
  4. {
  5. public SimpleSettingsNarrow()
  6. {
  7. this.InitializeComponent();
  8. DataContext = new TestViewModel("My Toggle Switch");
  9. }
  10.  
  11. private void MySettingsBackClicked(object sender, RoutedEventArgs e)
  12. {
  13. if (this.Parent.GetType() == typeof(Popup))
  14. {
  15. ((Popup)this.Parent).IsOpen = false;
  16. }
  17. SettingsPane.Show();
  18. }
  19. }
  20.  
  21. public class TestViewModel : INotifyPropertyChanged
  22. {
  23. public event PropertyChangedEventHandler PropertyChanged;
  24. private string _toggleSwitchText;
  25.  
  26. public TestViewModel(string text)
  27. {
  28. ToggleSwitchText = text;
  29. }
  30.  
  31. public string ToggleSwitchText
  32. {
  33. get { return _toggleSwitchText; }
  34. set
  35. {
  36. if (value != _toggleSwitchText)
  37. {
  38. _toggleSwitchText = value;
  39. NotifyPropertyChanged();
  40. }
  41. }
  42. }
  43.  
  44. private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
  45. {
  46. if (PropertyChanged != null)
  47. {
  48. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  49. }
  50. }
  51. }
  52. }
  53.  
  54. <UserControl
  55. x:Class="SettingsExample.SimpleSettingsNarrow"
  56. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  57. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  58. xmlns:local="using:SettingsExample"
  59. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  60. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  61. mc:Ignorable="d"
  62. d:DesignHeight="768"
  63. d:DesignWidth="346">
  64.  
  65. <UserControl.Resources>
  66. ...
  67. </UserControl.Resources>
  68.  
  69. <Border BorderBrush="Black" BorderThickness="1,0,0,0">
  70. <Grid Background="White" VerticalAlignment="Stretch">
  71. <!-- Root grid definition -->
  72. <Grid.RowDefinitions>
  73. <RowDefinition Height="80" />
  74. <RowDefinition Height="*" />
  75. </Grid.RowDefinitions>
  76.  
  77. <Grid Background="Orange" Grid.Row="0">
  78.  
  79. <Grid Margin="40,32,17,13">
  80.  
  81. <Grid.Transitions>
  82. <TransitionCollection>
  83. <EntranceThemeTransition FromHorizontalOffset="50" />
  84. </TransitionCollection>
  85. </Grid.Transitions>
  86.  
  87. <Grid.ColumnDefinitions>
  88. <ColumnDefinition Width="30" />
  89. <ColumnDefinition Width="*" />
  90. <ColumnDefinition />
  91. </Grid.ColumnDefinitions>
  92.  
  93. <Button Click="MySettingsBackClicked" Margin="0,3,0,0" Grid.Column="0" Style="{StaticResource SettingsBackButtonStyle}" HorizontalAlignment="Left" />
  94.  
  95. <TextBlock Margin="10,0,0,0" Grid.Column="1" FontFamily="Segoe UI" FontWeight="SemiLight" FontSize="24.6667" Text="Sound Options" HorizontalAlignment="Left" />
  96.  
  97. <Image Source="Assets/SmallLogo.png" HorizontalAlignment="Right" Grid.Column="2" Margin="0,0,6,0" />
  98.  
  99. </Grid>
  100.  
  101. </Grid>
  102.  
  103. <Grid Grid.Row="1" Margin="40,24,23,0" VerticalAlignment="Top">
  104. <Grid.Transitions>
  105. <TransitionCollection>
  106. <EntranceThemeTransition FromHorizontalOffset="120" />
  107. </TransitionCollection>
  108. </Grid.Transitions>
  109.  
  110. <ToggleSwitch Header="{Binding ToggleSwitchText}" />
  111. </Grid>
  112. </Grid>
  113. </Border>
  114. </UserControl>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement