public NonterminalActionBar(NonterminalCollapsed nontCollapsedIn)
        {
            InitializeComponent();

            nontCollapsed = nontCollapsedIn;

            // nontCollapsed -> nontV -> nontTailD -> nontHeadD
            Init(nontCollapsedIn.Reference.Reference.Reference);
        }
        private void SelectedNonterminal(NonterminalCollapsed control, GrammarEventArgs eventArgs)
        {
            SelectedNonterminal(eventArgs);

            if (ControlSelected != null)
            {
                ControlSelected(control, eventArgs);
            }
        }
        private void expand(NonterminalCollapsed nonterminalCollapsed, GrammarEventArgs e)
        {
            lock (new System.Object())
            {
                // the reference to the tail v
                NonterminalTailV nonterminalTailV = (NonterminalTailV)e.Reference;

                if (!nonterminalTailV.IsExpanded)
                {
                    // expand the model (visualised grammar)
                    model.Functions.Expand(nonterminalTailV);

                    // expand the view
                    view.Functions.Expand(nonterminalCollapsed);
                }
            }
        }
 //public  event EventHandler ConcatenationControlEvent;
 // ...
 internal void Listen(NonterminalCollapsed nonterminalCollapsed)
 {
     nonterminalCollapsed.ControlEvent += new NonterminalCollapsed.ControlEventHandler(nonterminalCollapsed_ControlEvent);
 }
        /// <summary>
        /// Expands the view, assumes that the visualised grammar has been expanded
        /// </summary>
        /// <param name="control"></param>
        /// <param name="reference"></param>
        /// <returns></returns>
        public void Expand(NonterminalCollapsed control)
        {
            StackPanel parent = (control.Parent as StackPanel);
            if (parent == null)
                throw new Exception("The controls parent is not of type stack panel");

            // draw the control
            GrammarNodeVDrawVisitor visitor = new GrammarNodeVDrawVisitor();
            visitor.visit(control.Reference);

            // get the index of the nonterminal collapsed that wants to expand
            int index = parent.Children.IndexOf(control);
            if (index < 0)
                throw new Exception("Cant find child in my stack panel, uh oh!");

            parent.Children.RemoveAt(index);
            parent.Children.Insert(index, visitor.DrawnItem);
        }