|
@@ -1795,7 +1795,33 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
|
|
Assert.Equal(123, comboBox.SelectedItem);
|
|
Assert.Equal(123, comboBox.SelectedItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ [Theory]
|
|
|
|
+ [InlineData(false)]
|
|
|
|
+ [InlineData(true)]
|
|
|
|
+ public void Should_Use_StringFormat_Without_Braces(bool compileBindings)
|
|
|
|
+ {
|
|
|
|
+ using (UnitTestApplication.Start(TestServices.StyledWindow))
|
|
|
|
+ {
|
|
|
|
+ var xaml = $@"
|
|
|
|
+<Window xmlns='https://github.com/avaloniaui'
|
|
|
|
+ xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
|
|
|
|
+ xmlns:local='clr-namespace:Avalonia.Markup.Xaml.UnitTests.MarkupExtensions;assembly=Avalonia.Markup.Xaml.UnitTests'
|
|
|
|
+ x:DataType='local:TestDataContext'
|
|
|
|
+ x:CompileBindings='{compileBindings}'>
|
|
|
|
+ <TextBlock Name='textBlock' Text='{{Binding DecimalValue, StringFormat=c2}}'/>
|
|
|
|
+</Window>";
|
|
|
|
+ var window = (Window)AvaloniaRuntimeXamlLoader.Load(xaml);
|
|
|
|
+ var textBlock = window.FindControl<TextBlock>("textBlock");
|
|
|
|
+
|
|
|
|
+ var dataContext = new TestDataContext();
|
|
|
|
+ window.DataContext = dataContext;
|
|
|
|
+
|
|
|
|
+ Assert.Equal(string.Format("{0:c2}", TestDataContext.ExpectedDecimal)
|
|
|
|
+ , textBlock.GetValue(TextBlock.TextProperty));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
static void Throws(string type, Action cb)
|
|
static void Throws(string type, Action cb)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -1891,7 +1917,10 @@ namespace Avalonia.Markup.Xaml.UnitTests.MarkupExtensions
|
|
public static string StaticProperty => "World";
|
|
public static string StaticProperty => "World";
|
|
|
|
|
|
public ListItemCollectionView<int> GenericProperty { get; } = new();
|
|
public ListItemCollectionView<int> GenericProperty { get; } = new();
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ public const decimal ExpectedDecimal = 15.756m;
|
|
|
|
+ public decimal DecimalValue { get; set; } = ExpectedDecimal;
|
|
|
|
+
|
|
public class NonIntegerIndexer : NotifyingBase, INonIntegerIndexerDerived
|
|
public class NonIntegerIndexer : NotifyingBase, INonIntegerIndexerDerived
|
|
{
|
|
{
|
|
private readonly Dictionary<string, string> _storage = new Dictionary<string, string>();
|
|
private readonly Dictionary<string, string> _storage = new Dictionary<string, string>();
|