private void MouseLeftDownCommandExecute(MouseEventArgs param)
        {
            Point p = param.GetPosition(param.Source as UIElement);
            var res = VisualTreeHelper.HitTest(param.Source as UIElement, p);
            if (res.VisualHit is DependencyObject && res.VisualHit != null)
            {
                var result = Ancestors.FindAncestorOfType<ChordView>(res.VisualHit as DependencyObject);
                if (result != null)
                {
                    foreach (ChordLine line in ChordLines)
                    {
                        foreach (Chord chord in line.Chords)
                        {
                            if (chord.IsSelected) chord.IsSelected = false;
                        }
                    }

                    // Set selected chord:

                    _selectedChordView = (result as ChordView);
                    _selectedChord = ((result as ChordView).DataContext as Chord);
                    _selectedChord.IsSelected = true;

                    _mainWindowModel.NotesPlayed = _selectedChord.Notes;

                }
                else
                {
                    _selectedChordView = null;
                    if (_selectedChord != null)
                    {
                        _selectedChord.IsSelected = false;
                    }
                    _selectedChord = null;

                    _mainWindowModel.NotesPlayed = null;
                }
            }
            else
            {
                Console.WriteLine();
            }
        }
        private void BuildDocument(DocumentViewModel model)
        {
            ChordDocument.PageWidth = 850;
            ChordDocument.PageHeight = 1190;

            char[] sep = { '.' };
            var songTitle = model.Title.Split(sep)[0];

            Run title = new Run(songTitle);
            title.FontSize=40;

            Paragraph titlePar = new Paragraph();
            titlePar.Inlines.Add(title);
            titlePar.TextAlignment = TextAlignment.Center;
            titlePar.Margin = new Thickness(30);

            ChordDocument.Blocks.Add(titlePar);

            foreach (ChordLine line in model.ChordLines)
            {
                var section = new Section();
                var chordsPar = new Paragraph();
                chordsPar.Margin = new Thickness(0, 0, 10, 0);
                var grid = new NoteGrid();
                grid.DataContext = line;
                var gridPar = new Paragraph(new InlineUIContainer(grid));
                gridPar.Margin = new Thickness(10,0,10,0);

                var chords = new Canvas();
                chords.Height = 30;

                foreach (Chord chord in line.Chords)
                {
                    var chordView = new ChordView();
                    chordView.DataContext = chord;
                    chordView.MainBorder.BorderThickness = new Thickness(0);
                    chordView.MainBorder.BorderBrush = Brushes.Transparent;
                    chordView.MainBorder.BitmapEffect = null;
                    chordView.ChordLabel.FontSize = 20;
                    chords.Children.Add(chordView);
                }

                chordsPar.KeepWithNext = true;
                chordsPar.Inlines.Add(new InlineUIContainer(chords));

                section.Blocks.Add(chordsPar);
                section.Blocks.Add(gridPar);

                ChordDocument.Blocks.Add(section);
            }
        }