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)
8
using System.Windows.Controls;
9
using ICSharpCode.Data.EDMDesigner.Core.UI.Helpers;
13
namespace ICSharpCode.Data.EDMDesigner.Core.UI.UserControls
15
public class ToolBoxExpander : Expander
17
static ToolBoxExpander()
19
ResourceDictionaryLoader.LoadResourceDictionary("/UserControls/ToolBoxExpanderResourceDictionary.xaml");
22
private RowDefinition _rowDefinition;
23
private GridLength? _rowHeight;
25
private RowDefinition RowDefinition
29
if (_rowDefinition == null)
31
FrameworkElement parent = this;
32
while ((parent = parent.Parent as FrameworkElement) != null)
34
var grid = parent as Grid;
35
if (grid != null && grid.RowDefinitions.Any())
37
_rowDefinition = grid.RowDefinitions[Grid.GetRow(this)];
42
return _rowDefinition;
46
protected override void OnCollapsed()
48
_rowHeight = RowDefinition.Height;
49
RowDefinition.Height = GridLength.Auto;
53
protected override void OnExpanded()
56
if (_rowHeight.HasValue)
57
RowDefinition.Height = _rowHeight.Value;