自动调整状态栏/工具栏的可见性. [英] Auto Sizing statusbar/toolbar on visibilty.
问题描述
xaml在网格中显示了一个简单的布局,其中包含以下组件:
The xaml shows a simple layout in grid with following components:
1.主菜单-第1行
2.工具栏-第2行
3. TabControl-第3行
3. TabControl - row 3
4. StatusBar-第4行
4. StatusBar - row 4
现在我试图弄清楚以下事情:
Now I am trying to figure out following things:
1.在主菜单中,有两个选项可切换工具栏和状态栏的可见性,即,当用户单击时,可隐藏/取消隐藏工具栏和状态栏.
1. In the main menu there are two options to toggle visibility of toolbar and statusbar i.e. when user clicks it hides/unhides the toolbar and status bar.
2.隐藏工具栏/状态栏后,tabcontrol控件将自身扩展到新的可用空间.现在,如果我隐藏任何一个条,它都会显示一条空白条.
2. Upon hiding either toolbar/statusbar the tabcontrol show extend itself to the new available space. Right now it shows a blank strip if i hide either of the bars.
3.我想要工具栏功能,用户可以在其中拖动它以将其放置在应用程序的尺寸角或底部.诸如Visual Studio之类的东西管理工具栏.当我将鼠标移到左上角时我看到移动图标,但拖动没有成功 任何东西.
3. I want the toolbar functionality where in user can drag it to put on either size corners or bottom of the application. Something like visual studio manages the toolbars. I see the move icon when i take the mouse to left corner but dragging doesnt yeild anything.
4.我怀疑可能不是网格布局,而是刷新内容大小和工具栏移动.
4. I suspect it is the Grid layout which might not be he;ping in refreshing the content size and toolbar movement.
xaml代码是
<Window x:Class="MenuSize.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Menu Grid.Row="0" MenuItem.Click="Menu_Click">
<MenuItem Header="File">
<MenuItem Header="Toggle Status Bar" x:Name="toggleStatusBarMenu" />
<Separator></Separator>
<MenuItem Header="Toggle Tool Bar" x:Name="toggleToolBarMenu" />
</MenuItem>
</Menu>
<ToolBarTray Grid.Row="1" >
<ToolBar x:Name="toolbar">
<Button >Button 1</Button>
<Separator></Separator>
<Button >Button 2</Button>
</ToolBar>
</ToolBarTray>
<TabControl Background="AliceBlue" Grid.Row="2">
<TabItem Header="Tab 1"></TabItem>
<TabItem Header="Tab 2"></TabItem>
</TabControl>
<StatusBar Grid.Row="3" x:Name="statusBar">
<TextBlock Text="Status Bar"/>
</StatusBar>
</Grid>
</Window>
推荐答案
你好,
2.隐藏工具栏/状态栏后,tabcontrol控件将自身扩展到新的可用空间.现在,如果我隐藏任何一个条,它都会显示一个空白条
使用 statusBar.Visibility = Visibility.Collapsed; 而不是statusBar.Visibility = Visibility.Hidden;
Use statusBar.Visibility = Visibility.Collapsed; instead of statusBar.Visibility = Visibility.Hidden;
3.我想要工具栏功能,用户可以在其中拖动它以将其放置在应用程序的尺寸角或底部.诸如Visual Studio之类的东西管理工具栏.当我将鼠标移到左上角时看到移动图标,但拖动没有 没事.
3. I want the toolbar functionality where in user can drag it to put on either size corners or bottom of the application. Something like visual studio manages the toolbars. I see the move icon when i take the mouse to left corner but dragging doesnt yeild anything.
要实现此目的,您必须限制拖放功能.
In order to achieve this you have to implemnt the drag and drop functionality.
4.我怀疑不是网格布局,而是刷新内容大小和工具栏移动.
4. I suspect it is the Grid layout which might not be he;ping in refreshing the content size and toolbar movement.
工具栏布局正常.可见性=崩溃将解决此问题.
The toolbar layout is ok. Visibility = Collapsed will fix the problem.
祝你好运.
这篇关于自动调整状态栏/工具栏的可见性.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!