Skip to content

Commit 777bba0

Browse files
committed
code_review: PR #1478
- Style for `ContentPresenter` in `ItemsControl.Styles` also overrides the default style of TextBox - Use simple for-each-loop instead of Linq expr Signed-off-by: leo <[email protected]>
1 parent 81da026 commit 777bba0

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/Views/ExecuteCustomAction.axaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@
5656

5757
<ItemsControl IsVisible="{Binding ControlParameters, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}"
5858
ItemsSource="{Binding ControlParameters, Mode=OneWay}">
59-
<ItemsControl.Styles>
60-
<Style Selector="ContentPresenter">
61-
<Setter Property="Margin" Value="0,1,0,1"/>
62-
</Style>
63-
</ItemsControl.Styles>
64-
6559
<ItemsControl.ItemsPanel>
6660
<ItemsPanelTemplate>
6761
<StackPanel Orientation="Vertical"/>
@@ -70,7 +64,7 @@
7064

7165
<ItemsControl.DataTemplates>
7266
<DataTemplate DataType="vm:CustomActionControlTextBox">
73-
<Grid ColumnDefinitions="150,*">
67+
<Grid Height="32" ColumnDefinitions="150,*">
7468
<TextBlock Grid.Column="0"
7569
Text="{Binding Label}"
7670
HorizontalAlignment="Right" VerticalAlignment="Center"
@@ -85,7 +79,7 @@
8579
</DataTemplate>
8680

8781
<DataTemplate DataType="vm:CustomActionControlCheckBox">
88-
<Grid ColumnDefinitions="150,*">
82+
<Grid Height="32" ColumnDefinitions="150,*">
8983
<CheckBox Grid.Column="1"
9084
Content="{Binding Label}"
9185
ToolTip.Tip="{Binding ToolTip, Mode=OneWay}"
@@ -94,7 +88,7 @@
9488
</DataTemplate>
9589

9690
<DataTemplate DataType="vm:CustomActionControlPathSelector">
97-
<Grid ColumnDefinitions="150,*">
91+
<Grid Height="32" ColumnDefinitions="150,*">
9892
<TextBlock Grid.Column="0"
9993
Text="{Binding Label}"
10094
HorizontalAlignment="Right" VerticalAlignment="Center"

src/Views/ExecuteCustomAction.axaml.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Linq;
2+
33
using Avalonia.Controls;
44
using Avalonia.Input;
55
using Avalonia.Interactivity;
@@ -17,11 +17,15 @@ public ExecuteCustomAction()
1717

1818
private void OnLoaded(object sender, RoutedEventArgs e)
1919
{
20-
var firstFocusable = this
21-
.GetVisualDescendants()
22-
.OfType<InputElement>()
23-
.FirstOrDefault(x => x.Focusable && x.IsTabStop);
24-
firstFocusable?.Focus();
20+
var inputs = this.GetVisualDescendants();
21+
foreach (var input in inputs)
22+
{
23+
if (input is InputElement { Focusable: true, IsTabStop: true } focusable)
24+
{
25+
focusable.Focus();
26+
return;
27+
}
28+
}
2529
}
2630

2731
private async void SelectPath(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)