Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. using System.Windows;
  2.  
  3. namespace MicrosoftDaysFind22S.Controls
  4. {
  5. public partial class ToggleSwitchWithHelp
  6. {
  7. public ToggleSwitchWithHelp()
  8. {
  9. InitializeComponent();
  10. }
  11.  
  12. public string Header
  13. {
  14. get { return (string) GetValue(HeaderProperty); }
  15. set
  16. {
  17. HeaderTextBlock.Text = value;
  18. SetValue(HeaderProperty, value);
  19. }
  20. }
  21.  
  22. public bool IsChecked
  23. {
  24. get { return (bool)GetValue(IsCheckedProperty); }
  25. set
  26. {
  27. ToggleSwitcher.IsChecked = value;
  28. SetValue(IsCheckedProperty, value);
  29. }
  30. }
  31.  
  32. public static readonly DependencyProperty HeaderProperty =
  33. DependencyProperty.Register(
  34. "Header", typeof(string), typeof(ToggleSwitchWithHelp), new PropertyMetadata("Неизвестная настройка"));
  35.  
  36. public static readonly DependencyProperty IsCheckedProperty =
  37. DependencyProperty.Register(
  38. "IsChecked", typeof(bool), typeof(ToggleSwitchWithHelp), new PropertyMetadata(false));
  39.  
  40. private void ToggleSwitcher_CheckedChange(object sender, RoutedEventArgs e)
  41. {
  42. if (ToggleSwitcher.IsChecked != null) IsChecked = (bool) ToggleSwitcher.IsChecked;
  43. }
  44.  
  45. private void ToggleSwitcher_OnLoaded(object sender, RoutedEventArgs e)
  46. {
  47. ToggleSwitcher.IsChecked = IsChecked;
  48. }
  49.  
  50. public delegate void NotifyCallUserHelpPageEventHandler(string settingName);
  51.  
  52. public event NotifyCallUserHelpPageEventHandler CallUserHelpPage;
  53.  
  54. protected virtual void OnCallUserHelpPage()
  55. {
  56. NotifyCallUserHelpPageEventHandler handler = CallUserHelpPage;
  57. if (handler != null) handler(Header);
  58. }
  59.  
  60. private void HelpButtonClick(object sender, RoutedEventArgs e)
  61. {
  62. OnCallUserHelpPage();
  63. }
  64. }
  65. }
  66.  
  67. public void ToggleSwitchWithHelp_OnCallUserHelpPage(string settingName)
  68. {
  69.  
  70. }
  71.  
  72. <controls:ToggleSwitchWithHelp
  73. Header="Использование местонахождения"
  74. IsChecked="{Binding IsAllowUseMyGeopositionSetting, Converter={StaticResource SettingsConverter}, Mode=TwoWay, Source={StaticResource AppSettings}}"
  75. CallUserHelpPage="ToggleSwitchWithHelp_OnCallUserHelpPage"/>
  76.  
  77. public SettingsPage()
  78. {
  79. InitializeComponent();
  80.  
  81. ToggleSwitchWithHelp.CallUserHelpPage += ToggleSwitchWithHelp_OnCallUserHelpPage;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement