NavigationStateConverter.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Data;
  9. using System.Windows.Media;
  10. namespace TeamAAS_VP.ValueConverter
  11. {
  12. public class NavigationStateConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if (value == null || parameter == null)
  17. return Application.Current.FindResource("DefaultNavigationUnCheckedBackground") as SolidColorBrush;
  18. return value.ToString()== parameter.ToString() ? Application.Current.FindResource("DefaultNavigationCheckedBackground") as SolidColorBrush : Application.Current.FindResource("DefaultNavigationUnCheckedBackground") as SolidColorBrush;
  19. }
  20. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  21. {
  22. return parameter;
  23. }
  24. }
  25. public class NavigationStateConverter1 : IValueConverter
  26. {
  27. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  28. {
  29. if (value == null || parameter == null)
  30. return Application.Current.FindResource("DefaultNavigationUnCheckedFore") as SolidColorBrush;
  31. return value.ToString() == parameter.ToString() ? Application.Current.FindResource("DefaultNavigationCheckedFore") as SolidColorBrush : Application.Current.FindResource("DefaultNavigationUnCheckedFore") as SolidColorBrush;
  32. }
  33. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  34. {
  35. return parameter;
  36. }
  37. }
  38. }