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 <longshuang@msn.cn>
This commit is contained in:
leo
2025-07-01 09:28:13 +08:00
parent 81da026296
commit 777bba0593
2 changed files with 13 additions and 15 deletions

View File

@@ -56,12 +56,6 @@
<ItemsControl IsVisible="{Binding ControlParameters, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}"
ItemsSource="{Binding ControlParameters, Mode=OneWay}">
<ItemsControl.Styles>
<Style Selector="ContentPresenter">
<Setter Property="Margin" Value="0,1,0,1"/>
</Style>
</ItemsControl.Styles>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
@@ -70,7 +64,7 @@
<ItemsControl.DataTemplates>
<DataTemplate DataType="vm:CustomActionControlTextBox">
<Grid ColumnDefinitions="150,*">
<Grid Height="32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
Text="{Binding Label}"
HorizontalAlignment="Right" VerticalAlignment="Center"
@@ -85,7 +79,7 @@
</DataTemplate>
<DataTemplate DataType="vm:CustomActionControlCheckBox">
<Grid ColumnDefinitions="150,*">
<Grid Height="32" ColumnDefinitions="150,*">
<CheckBox Grid.Column="1"
Content="{Binding Label}"
ToolTip.Tip="{Binding ToolTip, Mode=OneWay}"
@@ -94,7 +88,7 @@
</DataTemplate>
<DataTemplate DataType="vm:CustomActionControlPathSelector">
<Grid ColumnDefinitions="150,*">
<Grid Height="32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
Text="{Binding Label}"
HorizontalAlignment="Right" VerticalAlignment="Center"

View File

@@ -1,5 +1,5 @@
using System;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
@@ -17,11 +17,15 @@ namespace SourceGit.Views
private void OnLoaded(object sender, RoutedEventArgs e)
{
var firstFocusable = this
.GetVisualDescendants()
.OfType<InputElement>()
.FirstOrDefault(x => x.Focusable && x.IsTabStop);
firstFocusable?.Focus();
var inputs = this.GetVisualDescendants();
foreach (var input in inputs)
{
if (input is InputElement { Focusable: true, IsTabStop: true } focusable)
{
focusable.Focus();
return;
}
}
}
private async void SelectPath(object sender, RoutedEventArgs e)