Setting BorderBrush and BorderThickness for a button doesn't seem to work? #149
Replies: 3 comments
-
|
As workaround, try add this code before use triggers somewhere in applications initialization: if (!TypeDescriptor.GetAttributes(typeof(Avalonia.Thickness)).Cast<Attribute>().Any(x => x is TypeConverterAttribute))
{
TypeDescriptor.AddAttributes(typeof(Avalonia.Thickness), new TypeConverterAttribute(typeof(ThicknessTypeConverter)));
}
/*...*/
public class ThicknessTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || sourceType == typeof(double) || sourceType == typeof(int);
}
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
return value switch
{
string stringValue => new Avalonia.Thickness(double.Parse(stringValue, culture)),
double doubleValue => new Avalonia.Thickness(doubleValue),
int intValue => new Avalonia.Thickness(intValue),
_ => base.ConvertFrom(context, culture, value)
};
}
}
|
Beta Was this translation helpful? Give feedback.
-
|
Same problem but with padding: When trying to implement the suggested workaround I can cannot find class |
Beta Was this translation helpful? Give feedback.
-
|
Instead, it should be parsed compile time. But for that some attributes-hints should be created. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm on version 0.9.12 of everything. I'm trying to do the following:
That doesn't seem to work, but - as an alternate test, this does work:
Beta Was this translation helpful? Give feedback.
All reactions