C# Rad窗格和列表框可见性
我在rad窗格中有两个C# Rad窗格和列表框可见性,c#,wpf,silverlight,telerik,docking,C#,Wpf,Silverlight,Telerik,Docking,我在rad窗格中有两个ListBoxe,我希望一个ListBox对一个用户可见,两个列表框对另一个用户可见 当我制作列表框时,隐藏高度没有调整,它有一个空白 这是代码,请参考图片 <telerik:RadPane x:Name="customerfilterPane" Header="{Binding ApplicationStrings.CustomerPanelTitle, Source={StaticResource ResourceWrapper}}" CanUserClose="
ListBox
e,我希望一个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>
如果您能解决这个问题,我将不胜感激。您已经为两行指定了高度:
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
为了确保栅格折叠,需要为栅格行指定height=“auto”
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
显然,这将意味着网格单元将占用它们所需的任何空间(可能大小不正确)-在这种情况下,您可以在顶行上使用MinHeight
,以防止行缩小,或者确保子控件将自身设置为正确的大小。我找到了答案,我正在检查用户是否已登录,并在代码隐藏中将网格高度设置为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>
我试过了。。。运气不好,它仍然显示空白…TanqI将您的代码复制到silverlight项目中,并且上述更改对我有效,我将再看一次
<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;