2017-05-13 34 views
0

我想在用戶點擊十字圖標時創建關閉選項卡。我在幾天之前搜索了很多選擇。但我沒有找到確切的答案。關閉選項卡時,重點在ChromeTabs庫中的選項卡的交叉圖標WPF C#

<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. 

回答

0

我已經創建了windowform.Then我已創建回一個事件來關閉ChromeTab我創建GotFocus事件。此代碼關閉當前打開的選項卡。 轉到像這樣的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); 
       } 

      }