本文整理汇总了C#中RowDefinition.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# RowDefinition.SetBinding方法的具体用法?C# RowDefinition.SetBinding怎么用?C# RowDefinition.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RowDefinition
的用法示例。
在下文中一共展示了RowDefinition.SetBinding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColAndRowDefinitionsAreActuallyBindable
//https://bugzilla.xamarin.com/show_bug.cgi?id=31608
public void ColAndRowDefinitionsAreActuallyBindable ()
{
var rowdef = new RowDefinition ();
rowdef.SetBinding (RowDefinition.HeightProperty, "Height");
var grid = new Grid {
RowDefinitions = new RowDefinitionCollection { rowdef },
};
Assert.AreEqual (RowDefinition.HeightProperty.DefaultValue, rowdef.Height);
grid.BindingContext = new {Height = 32};
Assert.AreEqual (new GridLength(32), rowdef.Height);
}
示例2: ChangingRowHeightViaBindingTriggersRedraw
//https://bugzilla.xamarin.com/show_bug.cgi?id=31967
public void ChangingRowHeightViaBindingTriggersRedraw ()
{
var rowdef = new RowDefinition ();
rowdef.SetBinding (RowDefinition.HeightProperty, "Height");
var grid = new Grid {
// RowDefinitions = new RowDefinitionCollection {
// new RowDefinition { Height = GridLength.Auto },
// rowdef
// },
RowSpacing = 0,
Platform = new UnitPlatform (),
IsPlatformEnabled = true,
};
grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add (rowdef);
var label0 = new Label { IsPlatformEnabled = true };
Grid.SetRow (label0, 0);
var label1 = new Label { IsPlatformEnabled = true };
Grid.SetRow (label1, 1);
grid.BindingContext = new {Height = 0};
grid.Children.Add (label0);
grid.Children.Add (label1);
Assert.AreEqual (new SizeRequest (new Size (100, 20), new Size (0, 20)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
grid.BindingContext = new {Height = 42};
Assert.AreEqual (new SizeRequest (new Size (100, 62), new Size (0, 62)), grid.GetSizeRequest (double.PositiveInfinity, double.PositiveInfinity));
}
示例3: CreateDefinitions
private void CreateDefinitions( )
{
Debug.WriteLine($"{GameBoard.ActualHeight} x {GameBoard.ActualWidth}");
var rows = App.GameModel.Rows;
var columns = App.GameModel.Columns;
for(var i = 1; i <= rows; i++)
{
var heightBinding = new Binding("ActualHeight")
{
Converter = new SizeToGridLengthConverter(),
Source = GameBoard,
ConverterParameter = "Height"
};
var r = new RowDefinition();
r.SetBinding(RowDefinition.HeightProperty, heightBinding);
GameBoard.RowDefinitions.Add(r);
}
for(var i = 1; i <= columns; i++)
{
var widthBinding = new Binding("ActualWidth")
{
Converter = new SizeToGridLengthConverter(),
Source = GameBoard,
ConverterParameter = "Width"
};
var c = new ColumnDefinition();
c.SetBinding(ColumnDefinition.WidthProperty, widthBinding);
GameBoard.ColumnDefinitions.Add(c);
}
}