-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FocusVisuals): SystemFocusVisual control
- Loading branch information
1 parent
b70c4f4
commit 66293ac
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.cs
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,24 @@ | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace Uno.UI.Xaml.Controls | ||
{ | ||
public partial class SystemFocusVisual : Control | ||
{ | ||
public SystemFocusVisual() | ||
{ | ||
DefaultStyleKey = typeof(SystemFocusVisual); | ||
} | ||
|
||
protected override void OnApplyTemplate() => base.OnApplyTemplate(); | ||
|
||
public FrameworkElement FocusedElement | ||
{ | ||
get => (FrameworkElement)GetValue(FocusedElementProperty); | ||
set => SetValue(FocusedElementProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty FocusedElementProperty = | ||
DependencyProperty.Register(nameof(FocusedElement), typeof(FrameworkElement), typeof(SystemFocusVisual), new PropertyMetadata(default)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Uno.UI/UI/Xaml/Controls/FocusVisual/SystemFocusVisual.xaml
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,37 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:contract7Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,7)" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.Xaml.Controls"> | ||
|
||
<Style TargetType="local:SystemFocusVisual"> | ||
<Setter Property="AllowFocusOnInteraction" Value="False" /> | ||
<Setter Property="IsHitTestVisible" Value="False" /> | ||
<Setter Property="IsTapEnabled" Value="False" /> | ||
<Setter Property="IsTabStop" Value="False" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="local:SystemFocusVisual"> | ||
<Border | ||
Width="{Binding Path=FocusedElement.ActualWidth, RelativeSource={RelativeSource TemplatedParent}}" | ||
Height="{Binding Path=FocusedElement.ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"> | ||
<Border | ||
Background="{x:Null}" | ||
BorderBrush="{Binding Path=FocusedElement.FocusVisualPrimaryBrush, RelativeSource={RelativeSource TemplatedParent}}" | ||
BorderThickness="{Binding Path=FocusedElement.FocusVisualPrimaryThickness, RelativeSource={RelativeSource TemplatedParent}}" | ||
CornerRadius="{Binding Path=FocusedElement.CornerRadius, RelativeSource={RelativeSource TemplatedParent}}" | ||
Margin="{Binding Path=FocusedElement.FocusVisualMargin, RelativeSource={RelativeSource TemplatedParent}}"> | ||
<Border | ||
Background="Red" | ||
BorderBrush="{Binding Path=FocusedElement.FocusVisualSecondaryBrush, RelativeSource={RelativeSource TemplatedParent}}" | ||
BorderThickness="{Binding Path=FocusedElement.FocusVisualSecondaryThickness, RelativeSource={RelativeSource TemplatedParent}}" | ||
CornerRadius="{Binding Path=FocusedElement.CornerRadius, RelativeSource={RelativeSource TemplatedParent}}"> | ||
</Border> | ||
</Border> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
|
||
</ResourceDictionary> |
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