扩展器中的WrapPanel不会降低高度

时间:2016-05-13 10:47:40

标签: wpf xaml user-controls

我有一个简单的materialDesign:Card(其行为类似于Grid),内容为ExpanderExpander.Content设置为WrapPanel,其中包含ComboBoxes这样的简单组件,因此它们可以包含调整大小(展开时)。像魅力一样的工作期望materialDesign:Card不会缩回,直到我折叠Expander并再次展开它。

所以它看起来像那样:

enter image description here

这是我的XAML代码:

        <Grid Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <materialDesign:Card Grid.Row="0"
                                 Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                 AncestorType={x:Type Expander}},
                                                  Path=ActualHeight}"
                                 Margin="5"
                                 Background="White">
                <Expander Margin="10, 10, 10, 8"
                          HorizontalAlignment="Stretch"
                          HorizontalContentAlignment="Stretch"
                          materialDesign:ShadowAssist.ShadowDepth="Depth4"
                          IsExpanded="False">
                    <Expander.Header>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button Grid.Column="0"
                                    Height="35"
                                    Margin="5, 0"
                                    HorizontalAlignment="Stretch"
                                    HorizontalContentAlignment="Left"
                                    Focusable="False"
                                    FontSize="18"
                                    Style="{DynamicResource MaterialDesignToolButton}">
                                <materialDesign:PackIcon Width="22"
                                                         Height="22"
                                                         HorizontalAlignment="Center"
                                                         VerticalAlignment="Center"
                                                         Foreground="Black"
                                                         Kind="Magnify" />
                            </Button>
                            <TextBox Grid.Column="1"
                                     Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                                                                    AncestorType={x:Type Expander}},
                                                     Path=ActualWidth}"
                                     materialDesign:TextFieldAssist.Hint="Filmtitel"
                                     FontSize="16" />
                        </Grid>
                    </Expander.Header>
                    <WrapPanel Height="Auto" Orientation="Horizontal">
                        <ComboBox Width="160"
                                  Height="40"
                                  Margin="20, 10, 0, 0"
                                  VerticalContentAlignment="Center"
                                  DisplayMemberPath="Description"
                                  ItemsSource="{Binding GenreAuswahl,
                                                        Converter={converter:EnumToCollectionConverter},
                                                        Mode=OneTime}"
                                  SelectedValue="{Binding GenreAuswahl}"
                                  SelectedValuePath="Value" />
                        <ComboBox Width="100"
                                  Height="40"
                                  Margin="20, 10, 0, 0"
                                  VerticalContentAlignment="Center"
                                  DisplayMemberPath="Description"
                                  ItemsSource="{Binding FskAuswahl,
                                                        Converter={converter:EnumToCollectionConverter},
                                                        Mode=OneTime}"
                                  SelectedValue="{Binding FskAuswahl}"
                                  SelectedValuePath="Value" />
                        <TextBox Width="200"
                                 MaxWidth="200"
                                 Margin="20, 10, 0, 0"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 materialDesign:TextFieldAssist.Hint="Regisseuer" />
                        <materialDesign:RatingBar Margin="20, 10, 0, 0"
                                                  VerticalAlignment="Center"
                                                  Value="{Binding BewertungAuswahl}" />
                    </WrapPanel>
                </Expander>
            </materialDesign:Card>
        </Grid>

0 个答案:

没有答案