feat: 1. update container state from selection collection change.

2. Add popup slot.
3. fix various binding relative resource issue.
4. update empty pseudo-class handing, simplify watermark visibility.
This commit is contained in:
rabbitism
2024-08-24 12:59:58 +08:00
parent fc26ec7ce5
commit dffdcf3aa3
5 changed files with 174 additions and 95 deletions

View File

@@ -51,6 +51,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
Foreground="{TemplateBinding Foreground}"
IsHitTestVisible="False"
IsVisible="False"
Opacity="0.3"
Text="{TemplateBinding Watermark}" />
@@ -104,7 +105,7 @@
</Grid>
</Border>
<Popup
Width="{Binding #PART_RootGrid.Bounds.Width}"
MinWidth="{Binding #PART_RootGrid.Bounds.Width}"
MaxHeight="{TemplateBinding MaxDropdownHeight}"
IsLightDismissEnabled="True"
IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}"
@@ -118,16 +119,20 @@
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
ClipToBounds="True"
CornerRadius="6">
<ScrollViewer
Grid.IsSharedSizeScope="True"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
HorizontalAlignment="Stretch"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
<DockPanel LastChildFill="True">
<ContentPresenter Content="{TemplateBinding PopupInnerTopContent}" DockPanel.Dock="Top"/>
<ContentPresenter Content="{TemplateBinding PopupInnerBottomContent}" DockPanel.Dock="Bottom"/>
<ScrollViewer
Grid.IsSharedSizeScope="True"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter
Name="PART_ItemsPresenter"
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
HorizontalAlignment="Stretch"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</DockPanel>
</Border>
</Popup>
</Panel>
@@ -143,12 +148,12 @@
<Style Selector="^.clearButton, ^.ClearButton">
<Style Selector="^:pointerover:not(:selection-empty) /template/ Button#ClearButton">
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
<Setter Property="IsVisible" Value="True" />
</Style>
</Style>
<Style Selector="^:selection-empty /template/ TextBlock#PlaceholderTextBlock">
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
<Setter Property="IsVisible" Value="True" />
</Style>
<!-- Pointerover State -->