-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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.
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters