我在rad窗格中有两个ListBox
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>
我很乐意为你解决这个问题。
答案 0 :(得分: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
以防止行收缩,或确保子控件将自己设置为正确的大小。
答案 1 :(得分: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;