本文整理汇总了C#中System.Windows.Controls.GridSplitter类的典型用法代码示例。如果您正苦于以下问题:C# GridSplitter类的具体用法?C# GridSplitter怎么用?C# GridSplitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridSplitter类属于System.Windows.Controls命名空间,在下文中一共展示了GridSplitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMarginControls
protected virtual void CreateMarginControls()
{
int width;
using (var key = EditorExtensionsPackage.Instance.UserRegistryRoot)
{
var raw = key.GetValue("WE_" + _settingsKey);
width = raw is int ? (int)raw : -1;
}
width = width == -1 ? 400 : width;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Pixel) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width, GridUnitType.Pixel) });
grid.RowDefinitions.Add(new RowDefinition());
_previewControl = CreatePreviewControl();
grid.Children.Add(_previewControl);
Children.Add(grid);
Grid.SetColumn(_previewControl, 2);
Grid.SetRow(_previewControl, 0);
GridSplitter splitter = new GridSplitter();
splitter.Width = 5;
splitter.ResizeDirection = GridResizeDirection.Columns;
splitter.VerticalAlignment = VerticalAlignment.Stretch;
splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
splitter.DragCompleted += splitter_DragCompleted;
grid.Children.Add(splitter);
Grid.SetColumn(splitter, 1);
Grid.SetRow(splitter, 0);
}
示例2: SplitNine
public SplitNine()
{
Title = "Split Nine";
Grid grid = new Grid();
grid.ShowGridLines = true;
Content = grid;
for (int i = 0; i < 3; i++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.RowDefinitions.Add(new RowDefinition());
}
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 3; y++)
{
Button btn = new Button();
btn.Content = "Row " + y + " and Column " + x;
grid.Children.Add(btn);
Grid.SetRow(btn, y);
Grid.SetColumn(btn, x);
}
}
GridSplitter split = new GridSplitter();
split.Width = 6;
grid.Children.Add(split);
Grid.SetRow(split, 1);
Grid.SetColumn(split, 1);
}
示例3: OnInitialized
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
RowDefinitions.Add(new RowDefinition());
RowDefinitions.Add(new RowDefinition());
ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200) });
ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5) });
ColumnDefinitions.Add(new ColumnDefinition());
Children.Add(NavigationFrame);
Children.Add(SelectionFrame);
Grid.SetRow(SelectionFrame, 2);
Children.Add(ViewFrame);
var gridSplitter = new GridSplitter { Width = 5, HorizontalAlignment = HorizontalAlignment.Stretch };
Children.Add(gridSplitter);
Grid.SetColumn(gridSplitter, 1);
Grid.SetColumn(ViewFrame, 2);
Grid.SetRowSpan(ViewFrame, 3);
Update();
}
示例4: CreateControls
protected override void CreateControls(IWpfTextViewHost host, string source)
{
int width = WESettings.GetInt(SettingsKey);
width = width == -1 ? 400 : width;
_browser = new WebBrowser();
_browser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
Grid grid = new Grid();
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(0, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5, GridUnitType.Pixel) });
grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(width) });
grid.RowDefinitions.Add(new RowDefinition());
grid.Children.Add(_browser);
this.Children.Add(grid);
Grid.SetColumn(_browser, 2);
Grid.SetRow(_browser, 0);
GridSplitter splitter = new GridSplitter();
splitter.Width = 5;
splitter.ResizeDirection = GridResizeDirection.Columns;
splitter.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
splitter.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
splitter.DragCompleted += splitter_DragCompleted;
grid.Children.Add(splitter);
Grid.SetColumn(splitter, 1);
Grid.SetRow(splitter, 0);
}
示例5: ShowActualWidthToolTip
/// <summary>
/// ShowActualWidthToolTip shows actual width of the left and right column near the GridSplitter column, so one can split two columns precisely
/// </summary>
/// <param name="gs"></param>
/// <param name="tt"></param>
// TODO: MainWindow.ShowActualWidthToolTip seems to be to tricky for reusability, maybe one find a more scaleable solution
private void ShowActualWidthToolTip(GridSplitter gs, ToolTip tt)
{
// If the GridSplitter isn't positioned correctly in a seperate column between two other columns, drop functionality
Grid parentGrid = gs.Parent as Grid;
double? leftColumnActualWidth = null;
double? rightColumnActualWidth = null;
try
{
leftColumnActualWidth = parentGrid.ColumnDefinitions[(Grid.GetColumn(gs) - 1)].ActualWidth;
rightColumnActualWidth = parentGrid.ColumnDefinitions[Grid.GetColumn(gs) + 1].ActualWidth;
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Something went wrong in your GridSplitter layout. Splitter must been set in a column between the two columns who method tries to evaluate actual width. \n\n" + ex.Message, "Error", MessageBoxButton.OK);
}
tt.Content = String.Format("\u21E4 Width left {0} | {1} Width right \u21E5", leftColumnActualWidth, rightColumnActualWidth);
tt.PlacementTarget = this;
tt.Placement = PlacementMode.Relative;
tt.HorizontalOffset = (Mouse.GetPosition(this).X - (tt.ActualWidth / 2));
tt.VerticalOffset = (Mouse.GetPosition(this).Y + 10);
tt.IsOpen = true;
return;
}
示例6: CollapseColumn
void CollapseColumn(GridSplitter splitter, ColumnDefinition def, string content)
{
// Ignore collapse if popup is opened
if (PopupManager.ActivePopup != null)
return;
int collapsed = 0;
// Count the number of collapsed items (exclusing collapseView and rockScroll)
for (int i = 0; i < OverviewContainerRootGrid.ColumnDefinitions.Count -2; i++)
{
if (OverviewContainerRootGrid.ColumnDefinitions[i].Width.Value == 0)
collapsed++;
}
// Only allowed to collapse when there are at least two columns which have Width > 0
if (collapsed >= OverviewContainerRootGrid.ColumnDefinitions.Count - 3)
return;
GridColumnSizeHelper.SetPreviousGridLength(def, def.Width);
//Start Collapse Column Animation, only when the column Width != 0
if (def.Width != new GridLength(0))
{
Storyboard CollapseColumnGrid = (Storyboard)FindResource("CollapseColumn");
Storyboard.SetTarget(CollapseColumnGrid, def);
GridLengthAnimation gla = CollapseColumnGrid.Children[0] as GridLengthAnimation;
gla.From = def.Width;
gla.To = new GridLength(0);
CollapseColumnGrid.Begin(this);
}
if (splitter != null)
splitter.IsEnabled = false;
collapseView.AddCollapsedView(def, content, delegate
{
//Start Expand Column Animation, only when the column Width = 0
if (def.Width == new GridLength(0))
{
def.Width = GridColumnSizeHelper.GetPreviousGridLength(def);
GridLength previousWidth = def.Width;
def.Width = new GridLength(0);
Storyboard ExpandColumnGrid = (Storyboard)FindResource("CollapseColumn");
Storyboard.SetTarget(ExpandColumnGrid, def);
GridLengthAnimation gla = ExpandColumnGrid.Children[0] as GridLengthAnimation;
gla.From = new GridLength(0);
gla.To = previousWidth;
ExpandColumnGrid.Begin(this);
}
if (splitter != null)
splitter.IsEnabled = true;
});
}
示例7: OnInitialized
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
initialized = true;
ColumnDefinitions.Add(new ColumnDefinition ());
ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5) });
ColumnDefinitions.Add(new ColumnDefinition());
Children.Add(instances);
instances.SelectionChanged += Instances_SelectionChanged;
var splitter = new GridSplitter { Width = 5, HorizontalAlignment = HorizontalAlignment.Stretch };
Children.Add(splitter);
Grid.SetColumn(splitter, 1);
Grid.SetRowSpan(splitter, 2);
properties = new Properties { DataContext = null };
var scrollViewer = new ScrollViewer {
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Content = properties
};
Children.Add(scrollViewer);
Grid.SetColumn(scrollViewer, 2);
Update();
}
示例8: GridDefinitionBindingHelper
/// <summary>
/// Creates an instance of the GridDefinitionBindingHack class.
/// </summary>
private GridDefinitionBindingHelper(GridSplitter s, BindableObject o, BindableProperty p, BindableProperty p2)
{
// preconditions
Argument.IsNotNull("s", s);
Argument.IsNotNull("o", o);
Argument.IsNotNull("p", p);
// implementation
this.splitter = s;
this.bindableObject = o;
this.sizeProperty = p;
this.visibleProperty = p2;
// update the property if the column width/row height changes.
s.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e)
{
this.AdjustPropertyValue();
};
// update the column width/row height if the property value changes.
o.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == this.sizeProperty.Name ||
(this.visibleProperty != null && e.PropertyName == this.visibleProperty.Name))
{
this.AdjustDefinationValue();
}
};
}
示例9: SplitNine
public SplitNine()
{
Title = "Split Nine";
Grid grid = new Grid();
Content = grid;
// Set row and column definitions.
for (int i = 0; i < 3; i++)
{
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.RowDefinitions.Add(new RowDefinition());
}
// Create 9 buttons.
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
{
Button btn = new Button();
btn.Content = "Row " + y + " and Column " + x;
grid.Children.Add(btn);
Grid.SetRow(btn, y);
Grid.SetColumn(btn, x);
}
// Create splitter.
GridSplitter split = new GridSplitter();
split.Width = 6;
grid.Children.Add(split);
Grid.SetRow(split, 1);
Grid.SetColumn(split, 1);
}
示例10: Update
public void Update(GridSplitter gs, Grid grid)
{
Rows.Clear();
Cols.Clear();
Rows.AddRange(grid.RowDefinitions.Select(d => (DtoGridLength)d.Height));
Cols.AddRange(grid.ColumnDefinitions.Select(d => (DtoGridLength)d.Width));
}
示例11: OnApplyTemplate
public override void OnApplyTemplate() {
base.OnApplyTemplate();
PART_LeftSplitter = GetTemplateChild("PART_LeftSplitter") as GridSplitter;
PART_RightSplitter = GetTemplateChild("PART_RightSplitter") as GridSplitter;
PART_TopSplitter = GetTemplateChild("PART_TopSplitter") as GridSplitter;
PART_BottomSplitter = GetTemplateChild("PART_BottomSplitter") as GridSplitter;
PART_LeftSection = GetTemplateChild("PART_LeftSection") as ColumnDefinition;
PART_RightSection = GetTemplateChild("PART_RightSection") as ColumnDefinition;
PART_TopSection = GetTemplateChild("PART_TopSection") as RowDefinition;
PART_BottomSection = GetTemplateChild("PART_BottomSection") as RowDefinition;
PART_LeftCollapsedBar = GetTemplateChild("PART_LeftCollapsedBar") as ContentPresenter;
PART_RightCollapsedBar = GetTemplateChild("PART_RightCollapsedBar") as ContentPresenter;
PART_TopHeader = GetTemplateChild("PART_TopHeader") as ContentPresenter;
PART_BottomHeader = GetTemplateChild("PART_BottomHeader") as ContentPresenter;
PART_LeftSplitter.DragStarted += PART_LeftSplitter_DragStarted;
PART_RightSplitter.DragStarted += PART_RightSplitter_DragStarted;
PART_TopSplitter.DragStarted += PART_TopSplitter_DragStarted;
PART_BottomSplitter.DragStarted += PART_BottomSplitter_DragStarted;
PART_LeftSplitter.DragCompleted += PART_LeftSplitter_DragCompleted;
PART_RightSplitter.DragCompleted += PART_RightSplitter_DragCompleted;
PART_TopSplitter.DragCompleted += PART_TopSplitter_DragCompleted;
PART_BottomSplitter.DragCompleted += PART_BottomSplitter_DragCompleted;
PART_LeftSplitter.MouseDoubleClick += GridSplitter_MouseDoubleClick;
PART_RightSplitter.MouseDoubleClick += GridSplitter_MouseDoubleClick;
PART_TopSplitter.MouseDoubleClick += GridSplitter_MouseDoubleClick;
PART_BottomSplitter.MouseDoubleClick += GridSplitter_MouseDoubleClick;
}
示例12: AddSplitters
private void AddSplitters()
{
for (int j = 1; j < root.RowDefinitions.Count; ++j) {
GridSplitter gs = new GridSplitter();
root.Children.Add(gs);
gs.SetResourceReference(GridSplitter.StyleProperty, "ChatSplitter");
Grid.SetRow(gs, j);
}
}
示例13: switch
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.gridSplitter = ((System.Windows.Controls.GridSplitter)(target));
return;
}
this._contentLoaded = true;
}
示例14: SplitTheClient
public SplitTheClient()
{
Title = "Split the Client";
Grid grid1 = new Grid();
grid1.ColumnDefinitions.Add(new ColumnDefinition());
grid1.ColumnDefinitions.Add(new ColumnDefinition());
grid1.ColumnDefinitions.Add(new ColumnDefinition());
grid1.ColumnDefinitions[1].Width = GridLength.Auto;
Content = grid1;
Button btn = new Button();
btn.Content = "Button No.1";
grid1.Children.Add(btn);
Grid.SetRow(btn, 0);
Grid.SetColumn(btn, 0);
GridSplitter split = new GridSplitter();
split.ShowsPreview = true;
split.HorizontalAlignment = HorizontalAlignment.Center;
split.VerticalAlignment = VerticalAlignment.Stretch;
split.Width = 6;
grid1.Children.Add(split);
Grid.SetRow(split, 0);
Grid.SetColumn(split, 1);
Grid grid2 = new Grid();
grid2.RowDefinitions.Add(new RowDefinition());
grid2.RowDefinitions.Add(new RowDefinition());
grid2.RowDefinitions.Add(new RowDefinition());
grid2.RowDefinitions[1].Height = GridLength.Auto;
grid1.Children.Add(grid2);
Grid.SetRow(grid2, 0);
Grid.SetColumn(grid2, 2);
btn = new Button();
btn.Content = "Button No.2";
grid2.Children.Add(btn);
Grid.SetRow(btn, 0);
Grid.SetColumn(btn, 0);
split = new GridSplitter();
split.ShowsPreview = true;
split.HorizontalAlignment = HorizontalAlignment.Stretch;
split.VerticalAlignment = VerticalAlignment.Center;
split.Height = 6;
grid2.Children.Add(split);
Grid.SetRow(split, 1);
Grid.SetColumn(split, 0);
btn = new Button();
btn.Content = "Button No.3";
grid2.Children.Add(btn);
Grid.SetRow(btn, 2);
Grid.SetColumn(btn, 0);
}
示例15: Fix
private static void Fix(Grid grid, GridSplitter splitter)
{
var isColumn = splitter.HorizontalAlignment != HorizontalAlignment.Stretch;
if (!isColumn && splitter.VerticalAlignment == VerticalAlignment.Stretch)
isColumn = splitter.ActualWidth < splitter.ActualHeight;
if (isColumn)
FixColumn(grid, splitter);
else
FixRow(grid, splitter);
}