~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/Data/ICSharpCode.Data.EDMDesigner.Core.UI/UserControls/Expander.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System.Windows.Controls;
 
5
using System.Windows.Input;
 
6
using System.Windows.Controls.Primitives;
 
7
using ICSharpCode.Data.EDMDesigner.Core.UI.UserControls.Common;
 
8
using System.Windows;
 
9
using System.Windows.Automation.Peers;
 
10
using ICSharpCode.Data.EDMDesigner.Core.UI.Helpers;
 
11
 
 
12
namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls
 
13
{
 
14
    public class Expander : System.Windows.Controls.Expander
 
15
    {
 
16
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
 
17
        {
 
18
            base.OnPreviewMouseLeftButtonDown(e);
 
19
            if (VisualTreeHelperUtil.GetControlAscendant<TextBox>(e.OriginalSource) == null || VisualTreeHelperUtil.GetControlAscendant<EditableTextBlock>(e.OriginalSource) == null)
 
20
            {
 
21
                if (!(e.OriginalSource is FrameworkElement))
 
22
                    return;
 
23
 
 
24
                FrameworkElement control = (FrameworkElement)e.OriginalSource;
 
25
                while ((control = VisualTreeHelperUtil.GetControlAscendant<Grid>(control)) != null)
 
26
                    if (control.Name == "grdHeader")
 
27
                    {
 
28
                        ClickOnTheHeader();
 
29
                        break;
 
30
                    }
 
31
            }
 
32
        }
 
33
 
 
34
        protected virtual void ClickOnTheHeader()
 
35
        {
 
36
            DesignerCanvas designerCanvas = VisualHelper.GetVisualParent<DesignerCanvas>(this);
 
37
 
 
38
            if (designerCanvas != null)
 
39
                designerCanvas.Container.Selection = this.DataContext;
 
40
        }
 
41
    }
 
42
}