Hello Everyone I have created a small project in WPF. In this project I have a window with Menu Bar such as: Administration, Explorers, Reports. Each of these menus have sub menus: for instance under Administration Menu-Bar there is a sub-menu called Users, and under Explorers Menu-Bar there is a sub-menu called Menu Categories. My problem to my question is that on any of the sub-menus I click, it creates a dynamic tabitem and places them in the main tabcontrol (which this is fine), but if i click again on the same sub menus it repeats the same tabitems. Can someone please help me solve this problem. the source code for BackOfficeWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using iPosCloud.com.iposcloud.config.uiC_;
using iPosCloud.com.iposcloud.bo.uiC_.explorer;
using iPosCloud.com.iposcloud.bo.uiC_.explorer.ViewModel;
namespace iPosCloud.com.iposcloud.bo.uiC_
{
/// /// Interaction logic for BackOfficeWindow.xaml
///
public partial class BackOfficeWindow : Window
{
private VMBackOfficeWindow vmBackOfficeWindow;
public BackOfficeWindow()
{
InitializeComponent();
// create an object of ViewModel as set it as DataContext
vmBackOfficeWindow = new VMBackOfficeWindow();
this.DataContext = vmBackOfficeWindow;
ObservableCollectionTabItems = new ObservableCollection();
}
public ObservableCollection ObservableCollectionTabItems { get; set; }
// ADMINISTRATION MENU
private void menuItemAdminConfiguration\_Click(object sender, RoutedEventArgs e)
{
RestaurantConfigurationView rcv = new RestaurantConfigurationView();
//bow.Owner = this;
rcv.ShowDialog();
//this.Close();
}
#region "Close TabItems"
private void menuItem1\_Click(object sender, RoutedEventArgs e)
{
vmBackOfficeWindow.CloseTabItem(sender);
menuUsers.IsEnabled = true;
menuCategories.IsEnabled = true;