Skip to content

Error validation for usercontrol properties #17130

Answered by trashhacker
trashhacker asked this question in Q&A
Discussion options

You must be logged in to vote

Oh lord figured it out xD why do u have not implemented it as default why i have to implement it myself ? ...

public static readonly StyledProperty<string> UserTextProperty = 
    AvaloniaProperty.Register<TestUserControl, string>(nameof(UserText), defaultBindingMode:BindingMode.TwoWay, enableDataValidation:true);
public string UserText
{
    get => GetValue(UserTextProperty);
    set => SetValue(UserTextProperty, value);
}
public TestUserControl()
{
    InitializeComponent();
}
protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
{
    if (property == UserTextProperty)
    {
        DataValidationErrors.SetError(this, error);
 …

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@trashhacker
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@stevemonaco
Comment options

@trashhacker
Comment options

@timunie
Comment options

Answer selected by trashhacker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants