зеркало из https://github.com/DeGsoft/maui-linux.git
[C] change searchHandler bindingMode (#5776)
Change the default BindingMode for some properties - fixes #5706
This commit is contained in:
Родитель
170c8922c7
Коммит
92382c9703
|
@ -61,7 +61,7 @@ namespace Xamarin.Forms
|
|||
BindableProperty.Create(nameof(ClearIcon), typeof(ImageSource), typeof(SearchHandler), null, BindingMode.OneTime);
|
||||
|
||||
public static readonly BindableProperty ClearPlaceholderCommandParameterProperty =
|
||||
BindableProperty.Create(nameof(ClearPlaceholderCommandParameter), typeof(object), typeof(SearchHandler), null, BindingMode.OneTime,
|
||||
BindableProperty.Create(nameof(ClearPlaceholderCommandParameter), typeof(object), typeof(SearchHandler), null,
|
||||
propertyChanged: OnClearPlaceholderCommandParameterChanged);
|
||||
|
||||
public static readonly BindableProperty ClearPlaceholderCommandProperty =
|
||||
|
@ -69,7 +69,7 @@ namespace Xamarin.Forms
|
|||
propertyChanged: OnClearPlaceholderCommandChanged);
|
||||
|
||||
public static readonly BindableProperty ClearPlaceholderEnabledProperty =
|
||||
BindableProperty.Create(nameof(ClearPlaceholderEnabled), typeof(bool), typeof(SearchHandler), false, BindingMode.OneWay);
|
||||
BindableProperty.Create(nameof(ClearPlaceholderEnabled), typeof(bool), typeof(SearchHandler), false);
|
||||
|
||||
public static readonly BindableProperty ClearPlaceholderHelpTextProperty =
|
||||
BindableProperty.Create(nameof(ClearPlaceholderHelpText), typeof(string), typeof(SearchHandler), null, BindingMode.OneTime,
|
||||
|
@ -84,7 +84,7 @@ namespace Xamarin.Forms
|
|||
propertyChanged: (b, o, n) => ((SearchHandler)b).UpdateAutomationProperties());
|
||||
|
||||
public static readonly BindableProperty CommandParameterProperty =
|
||||
BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(SearchHandler), null, BindingMode.OneTime,
|
||||
BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(SearchHandler), null,
|
||||
propertyChanged: OnCommandParameterChanged);
|
||||
|
||||
public static readonly BindableProperty CommandProperty =
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Xamarin.Forms.Xaml.UnitTests.Gh5706">
|
||||
<Shell.SearchHandler>
|
||||
<SearchHandler
|
||||
x:Name="searchHandler"
|
||||
Command="{Binding FilterCommand}"
|
||||
CommandParameter="{Binding Source={x:Reference searchHandler}, Path=Query}" />
|
||||
</Shell.SearchHandler>
|
||||
</Shell>
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Core.UnitTests;
|
||||
|
||||
namespace Xamarin.Forms.Xaml.UnitTests
|
||||
{
|
||||
public partial class Gh5706 : Shell
|
||||
{
|
||||
class VM
|
||||
{
|
||||
public VM()
|
||||
{
|
||||
FilterCommand = new Command((p) => Param = p);
|
||||
}
|
||||
|
||||
public Command FilterCommand { get; set; }
|
||||
|
||||
public object Param { get; set; }
|
||||
}
|
||||
|
||||
public Gh5706() => InitializeComponent();
|
||||
public Gh5706(bool useCompiledXaml)
|
||||
{
|
||||
//this stub will be replaced at compile time
|
||||
}
|
||||
|
||||
[TestFixture] class Tests
|
||||
{
|
||||
IReadOnlyList<string> _flags;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Device.PlatformServices = new MockPlatformServices();
|
||||
_flags = Device.Flags;
|
||||
Device.SetFlags(new List<string>() { ExperimentalFlags.ShellExperimental });
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Device.PlatformServices = null;
|
||||
Device.SetFlags(_flags);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReportSyntaxError([Values(false, true)]bool useCompiledXaml)
|
||||
{
|
||||
var layout = new Gh5706(useCompiledXaml);
|
||||
layout.searchHandler.BindingContext = new VM();
|
||||
|
||||
Assert.That(layout.searchHandler.CommandParameter, Is.Null);
|
||||
layout.searchHandler.Query = "Foo";
|
||||
Assert.That(layout.searchHandler.CommandParameter, Is.EqualTo("Foo"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче