Merge pull request #175 from tuskermanshu/TabUI

fix(tab): 修复选中后border样式异常问题
This commit is contained in:
qinware
2025-12-15 21:06:22 +08:00
committed by GitHub
2 changed files with 20 additions and 3 deletions
@@ -5,6 +5,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Interactivity;
using Avalonia.Layout;
@@ -97,7 +98,8 @@ public class CardTabControl : BaseTabControl
Debug.Assert(ItemsBindingDisposables.ContainsKey(tabItem));
var disposables = ItemsBindingDisposables[tabItem];
disposables.Add(BindUtils.RelayBind(this, EffectiveCardBorderRadiusProperty, tabItem, TabItem.CornerRadiusProperty));
disposables.Add(BindUtils.RelayBind(this, CardBorderThicknessProperty, tabItem, TabItem.BorderThicknessProperty));
// Use template-level priority so selected-state styles can override border thickness
disposables.Add(BindUtils.RelayBind(this, CardBorderThicknessProperty, tabItem, TabItem.BorderThicknessProperty, BindingMode.Default, BindingPriority.Template));
}
}
@@ -185,4 +187,4 @@ public class CardTabControl : BaseTabControl
}
}
}
}
}
@@ -36,10 +36,25 @@
<Setter Property="Margin" Value="{DynamicResource {x:Static atom:TabControlTokenKey.HorizontalItemMargin}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static atom:TabControlTokenKey.CardBg}}" />
<Setter Property="BorderBrush" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBorderSecondary}}" />
<Setter Property="BorderThickness" Value="{DynamicResource {x:Static atom:SharedTokenKey.BorderThickness}}" />
<Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorBgContainer}}" />
</Style>
<!-- 选中态按放置方向去掉靠内容侧的边框 -->
<Style Selector="^[TabStripPlacement=Top]:selected">
<Setter Property="BorderThickness" Value="1,1,1,0" />
</Style>
<Style Selector="^[TabStripPlacement=Bottom]:selected">
<Setter Property="BorderThickness" Value="1,0,1,1" />
</Style>
<Style Selector="^[TabStripPlacement=Left]:selected">
<Setter Property="BorderThickness" Value="1,1,0,1" />
</Style>
<Style Selector="^[TabStripPlacement=Right]:selected">
<Setter Property="BorderThickness" Value="0,1,1,1" />
</Style>
<Style Selector="^[TabStripPlacement=Top], ^[TabStripPlacement=Bottom]">
<Setter Property="Margin" Value="{DynamicResource {x:Static atom:TabControlTokenKey.HorizontalItemMargin}}" />
@@ -104,4 +119,4 @@
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>