1
// Copyright © Microsoft Corporation.
2
// This source is subject to the Microsoft Source License for Silverlight Controls (March 2008 Release).
3
// Please see http://go.microsoft.com/fwlink/?LinkID=111693 for details.
4
// All other rights reserved.
6
using System.Windows.Markup;
7
using System.Windows.Media;
8
using System.Diagnostics;
10
namespace System.Windows.Controls
13
/// Represents the control that shows a preview of the GridSplitter's redistribution of space between columns or rows of a Grid control
15
internal partial class PreviewControl : Control
17
#region Control Instantiation
20
/// Instantiate the PreviewControl
22
public PreviewControl()
24
// TranslateTransform is required to reposition the preview
25
this.RenderTransform = new TranslateTransform();
30
#region Public Members
33
/// Bind the the dimensions of the preview control to the associated grid splitter
35
/// <param name="gridSplitter">GridSplitter instance to target</param>
36
public void Bind(GridSplitter gridSplitter)
38
Debug.Assert(gridSplitter != null);
39
Debug.Assert(gridSplitter.Parent != null);
41
this.Style = gridSplitter.PreviewStyle;
42
this.Height = gridSplitter.ActualHeight;
43
this.Width = gridSplitter.ActualWidth;
44
Matrix locationMatrix = ((MatrixTransform)gridSplitter.TransformToVisual((UIElement)gridSplitter.Parent)).Matrix;
45
SetValue(Canvas.LeftProperty, locationMatrix.OffsetX);
46
SetValue(Canvas.TopProperty, locationMatrix.OffsetY);
50
/// Gets or sets the x-axis offset for the underlying render transform
56
Debug.Assert(this.RenderTransform is TranslateTransform);
57
return ((TranslateTransform)this.RenderTransform).X;
61
Debug.Assert(this.RenderTransform is TranslateTransform);
62
((TranslateTransform)this.RenderTransform).X = value;
67
/// Gets or sets the y-axis offset for the underlying render transform
73
Debug.Assert(this.RenderTransform is TranslateTransform);
74
return ((TranslateTransform)this.RenderTransform).Y;
78
Debug.Assert(this.RenderTransform is TranslateTransform);
79
((TranslateTransform)this.RenderTransform).Y = value;