Browse Source
Merge pull request #11135 from yexcoffier/fixes/removes-double-click-on-treeviewitem-toggle
Set double tap of a TreeViewItem on ContentPresenter instead of whole header
onformfactor_issue
Max Katz
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
7 additions and
4 deletions
-
src/Avalonia.Controls/TreeViewItem.cs
-
src/Avalonia.Themes.Fluent/Controls/TreeViewItem.xaml
-
src/Avalonia.Themes.Simple/Controls/TreeViewItem.xaml
|
|
|
@ -45,6 +45,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
private TreeView? _treeView; |
|
|
|
private Control? _header; |
|
|
|
private Control? _headerPresenter; |
|
|
|
private int _level; |
|
|
|
private bool _templateApplied; |
|
|
|
private bool _deferredBringIntoViewFlag; |
|
|
|
@ -255,15 +256,16 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) |
|
|
|
{ |
|
|
|
if (_header is InputElement previousInputMethod) |
|
|
|
if (_headerPresenter is InputElement previousInputMethod) |
|
|
|
{ |
|
|
|
previousInputMethod.DoubleTapped -= HeaderDoubleTapped; |
|
|
|
} |
|
|
|
|
|
|
|
_header = e.NameScope.Find<Control>("PART_Header"); |
|
|
|
_headerPresenter = e.NameScope.Find<Control>("PART_HeaderPresenter"); |
|
|
|
_templateApplied = true; |
|
|
|
|
|
|
|
if (_header is InputElement im) |
|
|
|
if (_headerPresenter is InputElement im) |
|
|
|
{ |
|
|
|
im.DoubleTapped += HeaderDoubleTapped; |
|
|
|
} |
|
|
|
|
|
|
|
@ -75,7 +75,6 @@ |
|
|
|
MinHeight="{TemplateBinding MinHeight}" |
|
|
|
TemplatedControl.IsTemplateFocusTarget="True"> |
|
|
|
<Grid Name="PART_Header" |
|
|
|
Background="Transparent" |
|
|
|
ColumnDefinitions="Auto, *" |
|
|
|
Margin="{TemplateBinding Level, Mode=OneWay, Converter={StaticResource TreeViewItemLeftMarginConverter}}"> |
|
|
|
<Panel Name="PART_ExpandCollapseChevronContainer" |
|
|
|
@ -88,6 +87,7 @@ |
|
|
|
<ContentPresenter Name="PART_HeaderPresenter" |
|
|
|
Grid.Column="1" |
|
|
|
Focusable="False" |
|
|
|
Background="Transparent" |
|
|
|
Content="{TemplateBinding Header}" |
|
|
|
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|
|
|
HorizontalAlignment="{TemplateBinding HorizontalAlignment}" |
|
|
|
|
|
|
|
@ -44,18 +44,19 @@ |
|
|
|
Focusable="True" |
|
|
|
TemplatedControl.IsTemplateFocusTarget="True"> |
|
|
|
<Grid Name="PART_Header" |
|
|
|
Background="Transparent" |
|
|
|
Margin="{TemplateBinding Level, |
|
|
|
Mode=OneWay, |
|
|
|
Converter={StaticResource LeftMarginConverter}}" |
|
|
|
ColumnDefinitions="16, *"> |
|
|
|
<ToggleButton Name="PART_ExpandCollapseChevron" |
|
|
|
Focusable="False" |
|
|
|
Background="Transparent" |
|
|
|
IsChecked="{TemplateBinding IsExpanded, |
|
|
|
Mode=TwoWay}" |
|
|
|
Theme="{StaticResource SimpleTreeViewItemToggleButtonTheme}" /> |
|
|
|
<ContentPresenter Name="PART_HeaderPresenter" |
|
|
|
Grid.Column="1" |
|
|
|
Background="Transparent" |
|
|
|
Padding="{TemplateBinding Padding}" |
|
|
|
HorizontalContentAlignment="{TemplateBinding HorizontalAlignment}" |
|
|
|
Content="{TemplateBinding Header}" |
|
|
|
|