1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Data;
- namespace FurnaceUI.Converter
- {
- public class StringToBoolConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- if (value == null) return false;
- string s = value.ToString();
- bool.TryParse(s, out bool rtn);
- return rtn;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class StringTVisibilityConvert : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Visibility visibility = Visibility.Collapsed;
- if (value != null)
- {
- string s = value.ToString();
- if (bool.TryParse(s, out bool rtn))
- {
- visibility = rtn ? Visibility.Visible : Visibility.Collapsed;
- }
- }
- return visibility;
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- return Binding.DoNothing;
- }
- }
- }
|