Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@
IsThreeState="True"
Unchecked="QuickAccent_SelectedLanguage_UnselectAll" />
<tkcontrols:SettingsExpander.Items>
<tkcontrols:SettingsCard>
<tkcontrols:SettingsCard
x:Name="LanguageSettingsCard"
HorizontalContentAlignment="Stretch"
ContentAlignment="Left"
Loaded="LanguageSettingsCard_Loaded"
SizeChanged="LanguageSettingsCard_SizeChanged">
<ListView
x:Name="QuickAccent_Language_Select"
MinWidth="{StaticResource SettingActionControlMinWidth}"
Expand All @@ -80,22 +85,18 @@
ItemTemplate="{StaticResource LanguageViewTemplate}"
ItemsSource="{x:Bind LanguagesCustomViewSource.View, Mode=OneWay}"
Loaded="QuickAccent_Language_Select_Loaded"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollMode="Disabled"
SelectionChanged="QuickAccent_SelectedLanguage_SelectionChanged"
SelectionMode="Multiple">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid
MaxWidth="{Binding ElementName=QuickAccent_Language, Path=ActualWidth}"
ItemWidth="280"
Orientation="Horizontal" />
<ItemsWrapGrid ItemWidth="280" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Width" Value="280" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,26 @@ private void QuickAccent_Language_Select_Loaded(object sender, RoutedEventArgs e

loadingLanguageListDontTriggerSelectionChanged = false;
}

private void LanguageSettingsCard_Loaded(object sender, RoutedEventArgs e)
{
UpdateLanguageListMaxWidth(sender as Control);
}

private void LanguageSettingsCard_SizeChanged(object sender, SizeChangedEventArgs e)
{
UpdateLanguageListMaxWidth(sender as Control);
}

private void UpdateLanguageListMaxWidth(Control card)
{
if (card is null)
{
return;
}

QuickAccent_Language_Select.MaxWidth =
card.ActualWidth - card.Padding.Left - card.Padding.Right;
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

card.ActualWidth - card.Padding.Left - card.Padding.Right can go negative (e.g., during initial layout when ActualWidth is 0, or if the card becomes narrower than its padding). FrameworkElement.MaxWidth does not accept negative values and can throw. Clamp the computed value to >= 0 (or at least QuickAccent_Language_Select.MinWidth) before assigning to QuickAccent_Language_Select.MaxWidth.

Suggested change
QuickAccent_Language_Select.MaxWidth =
card.ActualWidth - card.Padding.Left - card.Padding.Right;
var availableWidth = card.ActualWidth - card.Padding.Left - card.Padding.Right;
var minWidth = QuickAccent_Language_Select.MinWidth;
QuickAccent_Language_Select.MaxWidth = global::System.Math.Max(minWidth, availableWidth);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, @niels9001. I will add the defensive check around this to make sure it doesn't go negative.

I'm away atm, but can look at this later today.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added with commit f994129

}
}
}