扩张器不可拉伸

时间:2012-08-17 17:29:40

标签: wpf xaml expander

我有一个WPF应用程序,我使用扩展器。当我使膨胀机坍塌时,它会占据空间。是不是可以让它释放空间,在xaml?

以下是一些代码:

   <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition Height="3*"></RowDefinition>
        <RowDefinition Height="4*"></RowDefinition>
        <RowDefinition Height="2*"></RowDefinition>
  </Grid.RowDefinitions>
    <wpfx:BusyIndicator Name="BusyBar" IsBusy="{Binding IsBusy}" BusyContent="Uploading enrollment data..." Grid.Row="0" />

    <Expander Grid.Row="1" IsExpanded="True" Header="Enrollment Files Upload">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Margin="3, 10" Grid.Row="0">
                <TextBlock Text="Agencies:" VerticalAlignment="Center" />
                <ComboBox x:Name="Agencies" DisplayMemberPath="PrimaryName" SelectedValuePath="AgentId" 
                      SelectedItem="{Binding SelectedAgency}"
                      MinWidth="100" Margin="3,0,10,0" VerticalAlignment="Center" />
                <TextBlock Text="Worksheet:" VerticalAlignment="Center" />
                <TextBox x:Name="WorkSheetName" VerticalAlignment="Center" Margin="3,0,10,0" />
                <Button x:Name="UploadFile"
                MinWidth="70"
                Margin="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center" 
                attachProperties:ButtonIcon.Icon="Resources/Images/add.png"
                Content="Upload File"  IsEnabled="{Binding EnrollmentFiles.Any}"                           
                Style="{StaticResource ImageButtonStyle}" />

                <Button x:Name="EnrollmentDelete"
                    MinWidth="70"
                    Margin="2"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center" 
                    attachProperties:ButtonIcon.Icon="Resources/Images/Remove.png"
                    Content="Delete Enrollment"  IsEnabled="{Binding EnrollmentFiles.Any}"                           
                    Style="{StaticResource ImageButtonStyle}" />
            </StackPanel>

            <c1:C1FlexGrid x:Name="EnrollmentFiles" Grid.Row="1"
                AutoGenerateColumns="False"
                IsReadOnly="True" Width="Auto"
                ItemsSource="{Binding Path=EnrollmentFiles}"
                SelectionMode="Row" KeepCurrentVisible="True"
                SelectedItem="{Binding Path=SelectedEnrollmentFile, Mode=TwoWay}">
...
            </c1:C1FlexGrid>
        </Grid>   
    </Expander>

    <Expander Grid.Row="2" IsExpanded="True" Header="First Data Entry Records">

        <DataGrid x:Name="FirstEntries"
            AutoGenerateColumns="False"
            BaseControls:DataGridExtension.Columns="{Binding FirstEntryGridColumns}"
            CanUserAddRows="False" IsReadOnly="True"
            SelectedItem="{Binding Path=SelectedFirstEntry}">
...
        </DataGrid>

    </Expander>

    <Expander Grid.Row="3" IsExpanded="True" Header="Enrollment Files Upload">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="3" Margin="3,10">
 ...
            </StackPanel>

            <TextBlock x:Name="SelectedFirstEntry_NameOnAccount" Grid.Row="1" Grid.Column="0"  />
            <TextBlock x:Name="SelectedFirstEntry_AccountNo" Grid.Row="1" Grid.Column="1" Margin="3,0" />
            <TextBlock x:Name="SelectedFirstEntry_MeterNo" Grid.Row="1" Grid.Column="2" Margin="3,0"/>

            <DataGrid x:Name="Findings" Grid.Row="2" 
                 AutoGenerateColumns="False"
                 BaseControls:DataGridExtension.Columns="{Binding FindingsGridColumns}"
                 CanUserAddRows="False">
 ...
            </DataGrid>
        </Grid>
    </Expander>
</Grid>

由于

2 个答案:

答案 0 :(得分:2)

扩展器确实崩溃但你看不到它,因为你的行定义有不变的高度,试试:

<RowDefinition Height="auto"></RowDefinition>

(在顶部网格上)

答案 1 :(得分:0)

扩展器控制是一个奇怪的控制。关于使用的空间等,您需要避免一些事情。请查看documentation

具体来说,

  

“即使内容已折叠,也会显示边框。要设置尺寸   扩展内容区域,设置大小尺寸的内容   ScrollViewer上的Expander,或者如果你想要滚动功能   包含内容。“

所以看起来你必须重新考虑你的用户界面,并使用滚动浏览器使用固定内容大小,或者使用带有3个标签的TabControl?