SelectingItemsControl missing default control styling
See original GitHub issueShould work as similar to using a ItemsControl for displaying data, albeit if you want a barebone minimal control without any of the selection visual found in the ListBox control but still have the ability to control your own visual when an item is selected.
Example scenario:
<SelectingItemsControl
AutoScrollToSelectedItem="True"
Grid.IsSharedSizeScope="True"
ItemsSource="{Binding}"
SelectedItem="{Binding Selected}">
<SelectingItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="LabelColumn" />
<ColumnDefinition Width="25" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<HighlightTextBlock
Grid.Column="0"
HighlightText="{Binding Key.Selection}"
SelectionIndex="{Binding Key.SelectionIndex, Mode=TwoWay}"
Text="{Binding Key.Value}" />
<HighlightTextBlock
Grid.Column="2"
HighlightText="{Binding Value.Selection}"
Opacity="0.6"
SelectionIndex="{Binding Value.SelectionIndex, Mode=TwoWay}"
Text="{Binding Value.Value}" />
</Grid>
</DataTemplate>
</SelectingItemsControl.ItemTemplate>
</SelectingItemsControl>
I’ve had to manually added a control style copied from ItemsControl.
<ControlTheme x:Key="{x:Type SelectingItemsControl}" TargetType="SelectingItemsControl">
<Setter Property="Template">
<ControlTemplate>
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ItemsPresenter
Name="PART_ItemsPresenter"
AreHorizontalSnapPointsRegular="{TemplateBinding AreHorizontalSnapPointsRegular}"
AreVerticalSnapPointsRegular="{TemplateBinding AreVerticalSnapPointsRegular}"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
Issue Analytics
- State:
- Created 5 months ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
SelectingItemsControl.cs
Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET Foundation community project. - Avalonia/src/Avalonia.
Read more >Convert Most DirectProperty Occurrences to StyledProperty ...
We didn't, no. I have a WIP which converts SelectedItem and SelectedIndex in SelectingItemsControl to styled properties, but everything breaks ...
Read more >ComboBox Class - Avalonia UI Framework - API
public class ComboBox : SelectingItemsControl, IAvaloniaObjectDebug, INotifyPropertyChanged ... Gets or sets the font style used to draw the control's text.
Read more >MenuItem Class - Avalonia UI Framework - API
Raised when the control is attached to a rooted visual tree. Inherited from Visual ... Occurs when the styled element has finished initialization....
Read more >MenuItem Class - Typedescriptor
A menu item control. ↳, HeaderedSelectingItemsControl Base Class. ↳, SelectingItemsControl ... Fluent: Add missing MenuItem Header styles #4457.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I use a lot the SelectingItemsControl and each time I have to do custom template based on
ItemsControl
. It is really useful control please don’t make it abstract. It serves great use case betweenItemsControl
and ListBoxThere are two problems with this:
SelectingItemsControl
doesn’t specify an item container type, so how would selected items be marked as selected? For example if one’sItemsSource
contains a list of strings then the created containers would beContentPresenter
s. How would aContentPresenter
visually indicate that it’s selected?SelectingItemsControl
provides no user interaction handling, so even if you got selection displaying, the user wouldn’t be able to interact with the control.I fear by making this control have a visual representation but one which doesn’t actually indicate selection, we’d be confusing things even more. It would probably make more sense to make the control abstract IMO.