Silverlight 3 TabItem定位错误
07-06-2011 4:34 上午 |链接
嗨, 我们在 Silverlight 3 中遇到了 TabItem 在 TabControl 中的放置问题。我们最多可以显示 9 个选项卡。但问题是,对于不同的用户配置文件,选项卡的数量可能会减少,即我们相应地折叠不需要的选项卡。这会改变选项卡的显示方式。 下面是代表相同场景的示例代码:
<UserControl x:Class="TabControlTrial.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
<Grid x:Name="LayoutRoot">
<Controls:TabControl Name="tbATReportMainMenu" TabStripPlacement="Top" Margin="5" Visibility="Visible">
<Controls:TabItem Name="A" Header="XXXX XXXXX XXXXXX XXXXXX"
Visibility="Visible">
</Controls:TabItem>
<Controls:TabItem Name="B" Header="XXXXXXXXXXX XXXXXXXX XXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="C" Header="XXXXXXXXXXX XXXXXXX X XXXXXXXXXXX XXXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="D" Header="XXXXXXXXXXX XXXXXXX X XXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="E" Header="XXXXXXXXXXX XXXXXXXX XXXXXXXXXXXX XXXXXXXX XXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="F" Header="XXXXXXXXXXXX XXXXXX XXXXXX X XXXXXXX XXXXXXX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="G" Header="XXXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="H" Header="XXXXXXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="I" Header="XXXXXX XXXXXX XXX XXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
</Controls:TabControl>
</Grid>
当所有选项卡设置为可见时输出。
折叠选项卡 E 和 G 时的输出。
从上面的屏幕截图中可以看出,选项卡在对齐过程中发生了扭曲。 我们已尝试使用 TabItems 和 TabControl 的所有 Alignment 属性,但没有用。 另请注意,对齐方式可能会根据屏幕分辨率而变化。
有没有办法可以解决这个问题?
提前致谢。
07-06-2011 4:34 AM | LINK
Hi,
We are facing a problem in Silverlight 3 with the placement of TabItem in the TabControl. We have a maximum of 9 tabs to be displayed. But the problem is that for different user profiles, the number of tabs may decrease i.e. we collapse the not required tabs accordingly. This creates a change in the way the tabs are displayed.
Below is a sample code to represent the same scenario:
<UserControl x:Class="TabControlTrial.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" >
<Grid x:Name="LayoutRoot">
<Controls:TabControl Name="tbATReportMainMenu" TabStripPlacement="Top" Margin="5" Visibility="Visible">
<Controls:TabItem Name="A" Header="XXXX XXXXX XXXXXX XXXXXX"
Visibility="Visible">
</Controls:TabItem>
<Controls:TabItem Name="B" Header="XXXXXXXXXXX XXXXXXXX XXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="C" Header="XXXXXXXXXXX XXXXXXX X XXXXXXXXXXX XXXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="D" Header="XXXXXXXXXXX XXXXXXX X XXXXXXX XXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="E" Header="XXXXXXXXXXX XXXXXXXX XXXXXXXXXXXX XXXXXXXX XXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="F" Header="XXXXXXXXXXXX XXXXXX XXXXXX X XXXXXXX XXXXXXX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="G" Header="XXXXXXXX XXXXXX"
Visibility=" Visible " >
</Controls:TabItem>
<Controls:TabItem Name="H" Header="XXXXXXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
<Controls:TabItem Name="I" Header="XXXXXX XXXXXX XXX XXXX XX XXXXXXX XXXXXX"
Visibility="Visible" >
</Controls:TabItem>
</Controls:TabControl>
</Grid>
Output when all Tabs are set to visible.
Output when Tab E and G are collapsed.
As it can be seen from the screenshot above the Tabs get distorted in the alignment.
We have tried using all the Alignment properties for the TabItems and TabControl, but it is of no use.
Also note that the alignment can change based on screen resolutions.
Is there a way that this problem can be sorted?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我们通过xaml.cs动态添加TabItems而不是显示/隐藏TabItems,则可以解决上述问题。
The above problem can be solved if we add TabItems dynamically through xaml.cs rather than showing/hiding the TabItems.