0

ListBox在 rad 窗格中有两个 es,我希望一个ListBox用户可以看到一个,另一个用户可以看到两个列表框。

当我制作时ListBox,隐藏高度没有调整,它有一个空白。

这是代码,请参阅图片。

<telerik:RadPane x:Name="customerfilterPane"
Header="{Binding ApplicationStrings.CustomerPanelTitle, Source={StaticResource ResourceWrapper}}"
CanUserClose="False"
GotFocus="customerfilterPane_GotFocus"
telerik:StyleManager.Theme="Summer">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="50" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" >
                            <ListBox x:Name="lstCustomers"
                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                 VerticalAlignment="Stretch"
                                 VerticalContentAlignment="Stretch"
                                 ItemsSource="{Binding ItemList,
                                 Source={StaticResource CustomerViewModel}}"
                                 HorizontalAlignment="Stretch"
                                 HorizontalContentAlignment="Stretch"
                                 >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                <CheckBox x:Name="chkCustomer"
                                IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                Content="{Binding CustomerName}"
                                Click="chkCustomer_Click" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        </Border>

                        <Border  Grid.Row="1"  Margin="4" BorderThickness="3" CornerRadius="2"
                                  Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
                            <StackPanel Orientation="Vertical" Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}">
                                <TextBlock Text="{Binding ApplicationStrings.PlannerPanelTitle, Source={StaticResource ResourceWrapper}}" />

                                <ListBox x:Name="lstCustomerPlanner"    ScrollViewer.VerticalScrollBarVisibility="Auto"
                                 VerticalAlignment="Stretch" Height="180"
                                 Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
                                 VerticalContentAlignment="Stretch"
                                 ItemsSource="{Binding ItemList, Source={StaticResource PlannerViewModel}}"
                                 HorizontalAlignment="Stretch"
                                 HorizontalContentAlignment="Stretch"
                                 >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox x:Name="chkCustomerPlanner"
                                              IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                              Content="{Binding PlannerId}"
                                              Click="chkPlanner_Click" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        </StackPanel>
                        </Border>
                        <StackPanel Orientation="Horizontal"
                                    FlowDirection="LeftToRight"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Stretch"
                                    Grid.Row="2">
                            <Button Content="{Binding ApplicationStrings.CheckAll, Source={StaticResource ResourceWrapper}}"
                                    Style="{StaticResource StandardButtonStyle}"
                                    Click="Customer_CheckAll" Margin="0,0,4,0" />
                            <Button Content="{Binding ApplicationStrings.UncheckAll, Source={StaticResource ResourceWrapper}}"
                                    Margin="0 0 4 0"
                                    Style="{StaticResource StandardButtonStyle}"
                                    Click="Customer_UncheckAll" />
                            <Button Content="{Binding ApplicationStrings.Apply, Source={StaticResource ResourceWrapper}}"
                                    Margin="0 0 0 0" x:Name="btnCustApply"
                                    Style="{StaticResource StandardButtonStyle}"
                                    Click="Customer_Apply" />
                        </StackPanel>
                    </Grid>
                </telerik:RadPane>

在此处输入图像描述 在此处输入图像描述

我会很高兴你能解决这个问题。

4

2 回答 2

0

您已经为两行指定了高度:

<Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="*" />
    <RowDefinition Height="50" />
</Grid.RowDefinitions>

这意味着无论行的内容如何,​​行的高度都将始终遵循以下公式:

(Available Height - 50) / 2

为了确保网格折叠,您需要为网格行指定 height = "auto"

<Grid.RowDefinitions>
    <RowDefinition Height="auto" />
    <RowDefinition Height="auto" />
    <RowDefinition Height="50" />
</Grid.RowDefinitions>

显然,这将意味着网格单元将占用他们需要的任何空间(可能不是正确的大小) - 在这种情况下,您可以只MinHeight在顶行上使用以防止行缩小,或确保子控件设置自己到正确的尺寸。

于 2013-05-13T14:59:24.983 回答
0

我想通了,我正在检查用户是否已登录并将网格高度设置为 0 在后面的代码中,而不是将列表框放在堆栈面板中,我采用了一个单独的网格。现在我可以满足我的要求了..谢谢你的帮助....

                    <telerik:RadPane x:Name="storefilterPane"
                                 Header="{Binding ApplicationStrings.StorePanelTitle, Source={StaticResource ResourceWrapper}}"
                                 IsPinned="True"
                                 CanDockInDocumentHost="False"
                                 CanUserClose="False"
                                 CanUserPin="True"
                                 GotFocus="storefilterPane_GotFocus"
                                 telerik:StyleManager.Theme="Summer"
                                 >
                    <Grid>
                        <Grid.RowDefinitions>
                            <!--<RowDefinition Height="Auto"  />-->
                            <RowDefinition Height="*" x:Name="grplanner"/>
                            <RowDefinition Height="Auto"  />
                            <RowDefinition Height="*"  />
                            <RowDefinition Height="40" />
                        </Grid.RowDefinitions>

                        <Border HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch">
                        <!--<telerik:RadWrapPanel Grid.Row="0"
                                              Orientation="Vertical"
                                              HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch">-->
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>


                            <TextBlock  Text="{Binding ApplicationStrings.PlannerPanelTitle, Source={StaticResource ResourceWrapper}}"
                                 Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}"/>
                        <ListBox x:Name="lstStorePlanner"  
                                 VerticalAlignment="Stretch" 
                                 Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}"
                                 VerticalContentAlignment="Stretch" 
                                 ItemsSource="{Binding ItemList, Source={StaticResource PlannerViewModel}}"
                                 HorizontalAlignment="Stretch"
                                 HorizontalContentAlignment="Stretch"
                                 telerik:StyleManager.Theme="Summer"
                                 Grid.Row="1"
                                 >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox x:Name="chkStorePlanner"
                                              IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                              Content="{Binding PlannerId}"
                                              Click="chkPlanner_Click" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                            </Grid>
                        </Border>
                        <!--</telerik:RadWrapPanel>-->

                        <controls:ExtendedGridSplitter Grid.Row="1" x:Name="gridSplitterStore"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch"
                                           Height="8"
                                           CollapseMode="Next"
                                           Background="LightBlue" />


                        <Border Grid.Row="2" 
                                              HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch">
                        <!--<telerik:RadWrapPanel Grid.Row="2" 
                                              Orientation="Vertical"
                                              HorizontalAlignment="Stretch"
                                              VerticalAlignment="Stretch">-->
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>

                        <TextBlock  Text="{Binding ApplicationStrings.StorePanelTitle, Source={StaticResource ResourceWrapper}}" x:Name="tbStores"
                             Visibility="{Binding IsPanelHiddenToCustomer, Source={StaticResource PlannerViewModel},Converter={StaticResource InvertedBooleanToVisibilityConverter}}" />
                        <ListBox  x:Name="lstStores" 
                            VerticalAlignment="Stretch" 
                            Grid.Row="1" 
                            VerticalContentAlignment="Stretch"  ScrollViewer.VerticalScrollBarVisibility="Auto"
                            ItemsSource="{Binding ItemList, Source={StaticResource StoreLookupViewModel}}"
                            HorizontalAlignment="Stretch" 
                            HorizontalContentAlignment="Stretch"
                            telerik:StyleManager.Theme="Summer"
                            >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                        <CheckBox x:Name="chkStore"
                                        IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                        Content="{Binding StoreName}"
                                        Click="chkStore_Click" />
                                        </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                            </Grid>
                        <!--</telerik:RadWrapPanel >-->
                        </Border>
                        <StackPanel Orientation="Horizontal" x:Name="spStore"
                            FlowDirection="LeftToRight"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center" Margin="0,3"
                            Grid.Row="3">
                            <Button Content="{Binding ApplicationStrings.CheckAll, Source={StaticResource ResourceWrapper}}"
                                Style="{StaticResource StandardButtonStyle}" 
                                Click="Store_CheckAll" Margin="0,0,4,0" />
                            <Button Content="{Binding ApplicationStrings.UncheckAll, Source={StaticResource ResourceWrapper}}"
                                Margin="0 0 4 0"
                                Style="{StaticResource StandardButtonStyle}"
                                Click="Store_UncheckAll" />
                            <Button Content="{Binding ApplicationStrings.Apply, Source={StaticResource ResourceWrapper}}"
                                    Margin="0 0 0 0"  x:Name="btnStrApply"
                                    Style="{StaticResource StandardButtonStyle}"
                                    Click="Store_Apply" />
                        </StackPanel>
                    </Grid>
                </telerik:RadPane>

在后面的代码中

                grdCustPlanner.Height = new GridLength(0);
                grplanner.Height = new GridLength(0);
                gridSplitterCust.Visibility = Visibility.Collapsed;
                gridSplitterStore.Visibility = Visibility.Collapsed;
于 2013-05-24T21:07:03.567 回答