I've got this xaml: <TextBox x:Name="adminPasswordTextBox" Width="200" Height="20"…
- User
I've got this xaml: <TextBox.Text> <Binding.ValidationRules> </Binding.ValidationRules> </TextBox.Text>
Code the converter.
Assistant
Sure, I can help you code the converter. The converter you're looking for is one that changes the visibility of a control based on whether there's a validation error or not. Here's a simple implementation of such a converter in C#:
csharpusing System; using System.Windows; using System.Windows.Data; public class ErrorToVisbilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null || string.IsNullOrEmpty(value.ToString())) { return Visibility.Collapsed; } else { return Visibility.Visible; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }