SHARE
TWEET

Untitled

a guest Nov 14th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private ModelObject DataContextModel = new ModelObject()
  2. {
  3.     Minutes = 0,
  4.     Hour = 0
  5. };
  6.  
  7. ...
  8.  
  9. this.DataContext =  DataContextModel
  10.    
  11. public class ModelObject : INotifyPropertyChanged
  12. {
  13.     ...
  14.     bool LiveScrapingValue = true;
  15.     public bool LiveScraping
  16.     {
  17.         get { return LiveScrapingValue; }
  18.         set
  19.         {
  20.             LiveScrapingValue = value;
  21.         }
  22.     }
  23.     ...
  24.    
  25. <TabControl Name="ScraperLiveAttorneysTabControl" Visibility="{Binding LiveScraping, Converter={StaticResource boolToVisibilityConverter}}">
  26.    
  27. public class BooleanToVisibilityConverter : IValueConverter
  28. {
  29.  
  30.     public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  31.     {
  32.         if (!(value is bool))
  33.         {
  34.             if ((bool)value == true)
  35.             {
  36.                 return Visibility.Hidden;
  37.             }
  38.             else
  39.             {
  40.                 return Visibility.Visible;
  41.             }
  42.         }
  43.         return Visibility.Hidden;
  44.     }
  45.  
  46.     public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  47.     {
  48.         throw new NotImplementedException();
  49.     }
  50. }
  51.    
  52. <Controls:MetroWindow.Resources>
  53.     <local:BooleanToVisibilityConverter x:Key="boolToVisibilityConverter"/>
  54. </Controls:MetroWindow.Resources>
  55.    
  56. DataContextModel.LiveScraping = true;
RAW Paste Data
Top