Browse Source
Merge branch 'master' into fixes/edid
pull/5369/head
Steven Kirk
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
40 additions and
25 deletions
-
src/Avalonia.Base/Data/IndexerBinding.cs
-
src/Avalonia.Controls/ToolTipService.cs
-
src/Avalonia.Themes.Fluent/Controls/CheckBox.xaml
-
src/Avalonia.Themes.Fluent/Controls/RadioButton.xaml
-
tests/Avalonia.Controls.UnitTests/ToolTipTests.cs
|
|
|
@ -1,6 +1,4 @@ |
|
|
|
using System; |
|
|
|
|
|
|
|
namespace Avalonia.Data |
|
|
|
namespace Avalonia.Data |
|
|
|
{ |
|
|
|
public class IndexerBinding : IBinding |
|
|
|
{ |
|
|
|
@ -24,23 +22,7 @@ namespace Avalonia.Data |
|
|
|
object anchor = null, |
|
|
|
bool enableDataValidation = false) |
|
|
|
{ |
|
|
|
var mode = Mode == BindingMode.Default ? |
|
|
|
targetProperty.GetMetadata(target.GetType()).DefaultBindingMode : |
|
|
|
Mode; |
|
|
|
|
|
|
|
switch (mode) |
|
|
|
{ |
|
|
|
case BindingMode.OneTime: |
|
|
|
return InstancedBinding.OneTime(Source.GetObservable(Property)); |
|
|
|
case BindingMode.OneWay: |
|
|
|
return InstancedBinding.OneWay(Source.GetObservable(Property)); |
|
|
|
case BindingMode.OneWayToSource: |
|
|
|
return InstancedBinding.OneWayToSource(Source.GetSubject(Property)); |
|
|
|
case BindingMode.TwoWay: |
|
|
|
return InstancedBinding.TwoWay(Source.GetSubject(Property)); |
|
|
|
default: |
|
|
|
throw new NotSupportedException("Unsupported BindingMode."); |
|
|
|
} |
|
|
|
return new InstancedBinding(Source.GetSubject(Property), Mode, BindingPriority.LocalValue); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -38,9 +38,16 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
if (ToolTip.GetIsOpen(control) && e.NewValue != e.OldValue && !(e.NewValue is ToolTip)) |
|
|
|
{ |
|
|
|
var tip = control.GetValue(ToolTip.ToolTipProperty); |
|
|
|
|
|
|
|
tip.Content = e.NewValue; |
|
|
|
if (e.NewValue is null) |
|
|
|
{ |
|
|
|
Close(control); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var tip = control.GetValue(ToolTip.ToolTipProperty); |
|
|
|
|
|
|
|
tip.Content = e.NewValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -11,7 +11,6 @@ |
|
|
|
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|
|
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|
|
|
<Setter Property="MinWidth" Value="120" /> |
|
|
|
<Setter Property="MinHeight" Value="32" /> |
|
|
|
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> |
|
|
|
<Setter Property="FocusVisualMargin" Value="-7,-3,-7,-3" />--> |
|
|
|
|
|
|
|
@ -19,7 +19,6 @@ |
|
|
|
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|
|
|
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" /> |
|
|
|
<Setter Property="MinWidth" Value="120" /> |
|
|
|
<Setter Property="Template"> |
|
|
|
<ControlTemplate TargetType="RadioButton"> |
|
|
|
<Border Name="RootBorder" |
|
|
|
|
|
|
|
@ -270,6 +270,34 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
Assert.Empty(toolTip.Classes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Close_On_Null_Tip() |
|
|
|
{ |
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
{ |
|
|
|
var window = new Window(); |
|
|
|
|
|
|
|
var target = new Decorator() |
|
|
|
{ |
|
|
|
[ToolTip.TipProperty] = "Tip", |
|
|
|
[ToolTip.ShowDelayProperty] = 0 |
|
|
|
}; |
|
|
|
|
|
|
|
window.Content = target; |
|
|
|
|
|
|
|
window.ApplyTemplate(); |
|
|
|
window.Presenter.ApplyTemplate(); |
|
|
|
|
|
|
|
_mouseHelper.Enter(target); |
|
|
|
|
|
|
|
Assert.True(ToolTip.GetIsOpen(target)); |
|
|
|
|
|
|
|
target[ToolTip.TipProperty] = null; |
|
|
|
|
|
|
|
Assert.False(ToolTip.GetIsOpen(target)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal class ToolTipViewModel |
|
|
|
|