我创建了一个在应用程序运行时加载的起始页,但它也显示了我的 tabcontrol(用于编辑和图表的两个 tabitems)。
如何在启动时隐藏我的 tabcontrol 项目并仅在用户选择文件-> 新建时显示它?
非常感谢!
xml:
<TabControl Height="Auto" Name="tabControl1" Width="Auto">
<TabItem Header="Diagram" Name="DiagramTab"></TabItem>
<TabItem Header="Rulebase" Name="RuleTab" >
<Grid>
<TextBox Height="Auto" Name="RuleText" Width="Auto" Text="" AcceptsTab="True" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" GotFocus="FocusChanged" KeyDown="ContentChanged" HorizontalScrollBarVisibility="Visible" />
</Grid>
</TabItem>
</TabControl>
这是我的文件-> 新菜单项:
private void NewItem(object sender, RoutedEventArgs e)
{
ProcessNewCommand();
}
private void ProcessNewCommand()
{
if (dataChanged)
{
string sf = SaveFirst();
if (sf != "Cancel")
{
ClearState();
}
}
else
{
ClearState();
}
}
风格:
<Style TargetType="TabItem" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid>
<Border
Name="Border"
Background="LightBlue"
BorderBrush="Black"
BorderThickness="0"
CornerRadius="6,6,0,0" >
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="12,2,12,2"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="LightBlue" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="LightGray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>