关注ChromeTabs Library WPF C#中标签的十字图标时关闭标签

时间:2017-05-13 11:58:11

标签: c# wpf

我想在用户点击十字图标时创建关闭标签。我在几天之前搜索了许多替代选项。但我找不到确切的答案。

  <ct:ChromeTabControl   Background="#FF76828D"    Foreground="Black"   BorderThickness="2"  x:Name="chromeTabeControl"  Margin="224,31,-5,88"  ItemsSource="{Binding ItemCollection}"
                             SelectedItem="{Binding SelectedTab}"
                             AddTabCommand="{Binding AddTabCommand}"
                           CanMoveTabs="False"   CloseTabCommand="{Binding  CloseTabCommand}"  SelectedTabBrush="#FF909BA4" BorderBrush="#FF6A6262" AddTabButtonBrush="#FF8D3030" OpacityMask="Black" LayoutUpdated="chromeTabeControl_LayoutUpdated"    >
            <ct:ChromeTabItem     Name="dashboard_tab" Margin="0,0,0,0"   VerticalContentAlignment="Center" HorizontalContentAlignment="Center"  VerticalAlignment="Center" HorizontalAlignment="Center" Header="Dashboard"    >
            </ct:ChromeTabItem>
</ct:ChromeTabControl>

通过这样做,我可以删除tab.But我不知道如何在交叉图像图标上实现此操作。

            chromeTabeControl.Items.Remove (dashboard_tab );

Any one help me.He would be appricated for me.Thanks in advance.

1 个答案:

答案 0 :(得分:0)

我在windowform上创建了GotFocus事件。然后我创建了一个事件来关闭我创建的ChromeTab。此代码关闭打开的当前选项卡。 转到这样的XAML文件创建窗口事件。

 XAML:
    GotFocus="Window_GotFocus"

Code Behind :
 private void Window_GotFocus ( object sender, RoutedEventArgs e )
            {
            if ( e.OriginalSource.ToString ( ) ="System.Windows.Controls.Button") {
                chromeTabeControl.Items.Remove ( chromeTabeControl.SelectedItem );
                }

            }