Telerik et Controls WPF

De Banane Atomic
Révision datée du 13 mai 2020 à 09:08 par Nicolas (discussion | contributions) (→‎RadWatermarkTextBox)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigationAller à la recherche

RadGridView

Data Validation

public class MyViewModel : INotifyPropertyChanged, IDataErrorInfo
{
    public string Error { get; set; }
    public string this[string propertyName] => GetErrorForProperty(propertyName);
    private string GetErrorForProperty(string propertyName)
    {
        switch (propertyName)
        {
            case nameof(Name):
                {
                    if (Name.Contains("x"))
                    {
                        // insérer un message dans Error va colorer la ligne en rouge et remplir le tooltip du RowHeader
                        Error = "Error, name contains x.";
                    }
                    else
                    {
                        Error = "";
                    }
                    // renvoie toujours un string vide pour toujours valider la cellule
                    return string.Empty;
                }
            default:
                return string.Empty;
        }
    }

RadWatermarkTextBox

Xaml.svg
<Window xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <telerik:RadWatermarkTextBox WatermarkContent="Enter a value ..."
                                 CurrentText="{Binding MyValue, Mode=OneWayToSource}" />