Skip to content

Commit

Permalink
Fix SettingsGroup AOT/Trim Crash
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Nov 25, 2024
1 parent c2c04cb commit ad0e13d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
namespace DevWinUI;
public partial class SettingsGroup : Control
{
internal CornerRadius RootGridCornerRadius
{
get { return (CornerRadius)GetValue(RootGridCornerRadiusProperty); }
set { SetValue(RootGridCornerRadiusProperty, value); }
}

internal static readonly DependencyProperty RootGridCornerRadiusProperty =
DependencyProperty.Register(nameof(RootGridCornerRadius), typeof(CornerRadius), typeof(SettingsGroup), new PropertyMetadata(new CornerRadius(0)));
private CornerRadius GetRootGridCornerRadius()
{
return (CornerRadius)new Bool2CornerRadiusConverter().Convert(Items?.Count, null, null, null);
}
public ObservableCollection<object> Items
{
get { return (ObservableCollection<object>)GetValue(ItemsProperty); }
Expand All @@ -25,13 +37,10 @@ private void OnItemsChanged()
{
if (_itemsRepeater is not null)
{
Bool2CornerRadiusConverter bool2CornerRadiusConverter = new Bool2CornerRadiusConverter();
var cornerRadius = bool2CornerRadiusConverter.Convert(Items.Count, null, null, null);

RootGridCornerRadius = GetRootGridCornerRadius();
if (_rootGrid != null)
{
_rootGrid.CornerRadius = (CornerRadius)cornerRadius;

_rootGrid.CornerRadius = GetRootGridCornerRadius();
}

foreach (var item in Items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected override void OnApplyTemplate()
OnHeaderChanged();
OnDescriptionChanged();
OnContentChanged();
RootGridCornerRadius = GetRootGridCornerRadius();
base.OnApplyTemplate();
}

Expand Down
2 changes: 1 addition & 1 deletion dev/DevWinUI.Controls/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3825,7 +3825,7 @@ Themes\Styles\Win2D\Watermark.xaml
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="PART_RootGrid" Grid.Row="0" MinHeight="{ThemeResource SettingsCardMinHeight}" Padding="{ThemeResource SettingsCardPadding}" Background="{ThemeResource SettingsCardBackground}" BackgroundSizing="InnerBorderEdge" BorderBrush="{ThemeResource SettingsCardBorderBrush}" BorderThickness="{ThemeResource SettingsCardBorderThickness}" CornerRadius="{Binding Items.Count, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource Bool2CornerRadiusConverter}}">
<Grid x:Name="PART_RootGrid" Grid.Row="0" MinHeight="{ThemeResource SettingsCardMinHeight}" Padding="{ThemeResource SettingsCardPadding}" Background="{ThemeResource SettingsCardBackground}" BackgroundSizing="InnerBorderEdge" BorderBrush="{ThemeResource SettingsCardBorderBrush}" BorderThickness="{ThemeResource SettingsCardBorderThickness}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
Background="{ThemeResource SettingsCardBackground}"
BackgroundSizing="InnerBorderEdge"
BorderBrush="{ThemeResource SettingsCardBorderBrush}"
BorderThickness="{ThemeResource SettingsCardBorderThickness}"
CornerRadius="{Binding Items.Count, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource Bool2CornerRadiusConverter}}">
BorderThickness="{ThemeResource SettingsCardBorderThickness}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
Expand Down

0 comments on commit ad0e13d

Please sign in to comment.