在按鈕我必須的click事件創建兩個標籤下面的按鈕在按鈕的clickevent創建一個TabControl FOM代碼隱藏
私人無效bnOpen_Click(對象發件人,RoutedEventArgs E) {
}
在按鈕我必須的click事件創建兩個標籤下面的按鈕在按鈕的clickevent創建一個TabControl FOM代碼隱藏
私人無效bnOpen_Click(對象發件人,RoutedEventArgs E) {
}
我所做的是在這裏:
XAML:
主題:ThemeManager.StyleKey = 「SelectorDropDownButtonStyle」/>
<TextBox x:Name="txtFolderName" Themes:ThemeManager.StyleKey="TextBox" IsReadOnly="True" Grid.Column="0" />
</Grid>
<Controls:TabControl x:Name="tbc" HorizontalAlignment="Stretch" Width="auto" Grid.Row="1" HorizontalContentAlignment="Stretch">
<Controls:TabControl.Items >
<Controls:TabItem x:Name="brw" Header="Browse" Height="auto">
<Grid >
<Border x:Name="PopupOuterBorder" Themes:ThemeManager.StyleKey="ReportSelectorOuterBorder"/>
<Border x:Name="PopupInnerBorder" Background="#404040" Themes:ThemeManager.StyleKey="ReportSelectorPopupInnerBorder">
<ScrollViewer x:Name="scrollBar" HorizontalScrollBarVisibility="Auto" Height="100" Themes:ThemeManager.StyleKey="TreeScrollViewer" >
<Browser:FolderBrowser x:Name="folderPickerTree" SelectionChanged="tree_SelectionChanged" ></Browser:FolderBrowser>
</ScrollViewer>
</Border>
</Grid>
</Controls:TabItem>
<Controls:TabItem Header="Search" Height="auto" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox x:Name="tbSearch" Grid.Row="0" Grid.Column="0" Themes:ThemeManager.StyleKey="TextBox" TextChanged="SearchTextChangeEvent" />
<Button x:Name="bnSearch" Grid.Row="0" Grid.Column="1" Themes:ThemeManager.StyleKey="Button" Click="bnSearch_Click" Content="Search"/>
<ListBox x:Name="displayfolderList" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Height="30"></ListBox>
</Grid>
</Controls:TabItem>
</Controls:TabControl.Items>
</Controls:TabControl>
代碼背後:
公共FolderPickerControl() { InitializeComponent(); tbc.Visibility = Visibility.Collapsed; }
私人無效bnOpen_Click(對象發件人,RoutedEventArgs E) {
if (IsDesignTime)
return;
brw.IsSelected = true;
if (tbc.Visibility != Visibility.Visible)
{
tbc.Visibility = Visibility.Visible;
}
else
{
tbc.Visibility = Visibility.Collapsed;
}
}
你可以這樣做以下:
phTabHolder.Controls.Add(m_UCtlMyTabControl)
查看this for dynamically adding的一個控件。
那豈不是更容易有標籤控件已經存在,與Visible屬性設置爲false,然後設置按鈕點擊事件中的可見屬性爲true? – David 2009-12-03 06:30:49
+1思想同樣(: – 2009-12-03 06:42:09
我跟着thsi,我完成了 – Malcolm 2009-12-05 08:01:38