Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid.IsSharedSizeScope="True" is not working inside ComboBox Popup #17360

Open
AlexeiScherbakov opened this issue Oct 26, 2024 · 0 comments
Open
Labels

Comments

@AlexeiScherbakov
Copy link

Describe the bug

I redefined Style for creating custom ComboBox with popup with 2 columns, but Grid.IsSharedSizeScope="True" is not working

<Popup Name="PART_Popup"
       WindowManagerAddShadowHint="False"
       IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
       MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
       MaxHeight="{TemplateBinding MaxDropDownHeight}"
       PlacementTarget="Background"
       IsLightDismissEnabled="True"
       InheritsTransform="True">
  <Border x:Name="PopupBorder"
          Background="{DynamicResource ComboBoxDropDownBackground}"
          BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}"
          BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
          Padding="{DynamicResource ComboBoxDropdownBorderPadding}"
          HorizontalAlignment="Stretch"
          CornerRadius="{DynamicResource OverlayCornerRadius}"
          >
    <DockPanel Grid.IsSharedSizeScope="True">
      <TextBlock Text="This combobox is modified" DockPanel.Dock="Top"/>
      <ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                    VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                    IsDeferredScrollingEnabled="{TemplateBinding (ScrollViewer.IsDeferredScrollingEnabled)}"
                    HorizontalContentAlignment="Stretch">
        <ItemsPresenter Name="PART_ItemsPresenter"
                        Margin="{DynamicResource ComboBoxDropdownContentMargin}"
                        ItemsPanel="{TemplateBinding ItemsPanel}"
                        />
      </ScrollViewer>
    </DockPanel>
  </Border>
</Popup>

Custom Combobox
Same layout without popup is working

<DockPanel Grid.IsSharedSizeScope="True">
  <Grid DockPanel.Dock="Top">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="16"/>
      <ColumnDefinition Width="Auto" SharedSizeGroup="NameGroup"/>
      <ColumnDefinition Width="16"/>
      <ColumnDefinition Width="Auto" SharedSizeGroup="CountGroup"/>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Column="1" Text="Name"  Background="Red"/>
    <TextBlock Grid.Column="3" Text="Count" Background="Blue"/>
  </Grid>
  <ScrollViewer Margin="0">
    <ItemsControl ItemsSource="{Binding Path=Items}">
      <ItemsControl.ItemTemplate>
        <DataTemplate x:DataType="vm:Item">
           <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="16"/>
              <ColumnDefinition Width="Auto" SharedSizeGroup="NameGroup"/>
              <ColumnDefinition Width="16"/>
              <ColumnDefinition Width="Auto" SharedSizeGroup="CountGroup"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="1" Text="{Binding Path=Name}" Background="Red"/>
            <TextBlock Grid.Column="3" Text="{Binding Path=Count}" Background="Blue" />
          </Grid>
        </DataTemplate>
      </ItemsControl.ItemTemplate>
    </ItemsControl>
  </ScrollViewer>
</DockPanel>

Without popup

To Reproduce

Sample is located here - https://github.com/AlexeiScherbakov/AvaloniaGridSharedScopeBug

Expected behavior

IsSharedSizeScope is working

Avalonia version

11.0.0, 11.0.4

OS

Windows

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant