Browse Source
This issue only shows up when using the cecil backend for XamlX and so can't easily be tested with unit tests. The easiest way to test it is to add it to a sample project, `BindingDemo` is as good as anywhere I think.pull/15367/head
committed by
GitHub
3 changed files with 59 additions and 0 deletions
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace BindingDemo; |
||||
|
|
||||
|
internal class GenericMarkupExtension<T> : MarkupExtension |
||||
|
{ |
||||
|
public T Value { get; set; } |
||||
|
|
||||
|
public override object ProvideValue(IServiceProvider serviceProvider) |
||||
|
{ |
||||
|
return $"{Value?.GetType().Name}: {Value}"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Globalization; |
||||
|
using Avalonia.Data.Converters; |
||||
|
|
||||
|
#nullable enable |
||||
|
|
||||
|
namespace BindingDemo; |
||||
|
|
||||
|
public class GenericValueConverter<T> : IValueConverter |
||||
|
{ |
||||
|
public GenericValueConverter() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
||||
|
{ |
||||
|
if (value is T) |
||||
|
{ |
||||
|
return $"{typeof(T).Name}: {value}"; |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue