我創建了一個啓動頁面,它在應用程序運行時加載,但它也顯示我的tabcontrol(兩個用於編輯&圖形的Tabitems)。WPF C#在應用程序啓動時隱藏TabControl項目
如何在啓動時隱藏我的tabcontrol項目,並且只在用戶選擇文件 - >新建時才顯示它?
非常感謝!
的XAML:
<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>
你可以發表一些代碼。 – VoodooChild
當然,補充! –