本文整理汇总了C#中PropertyDefinition.CreateBinding方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDefinition.CreateBinding方法的具体用法?C# PropertyDefinition.CreateBinding怎么用?C# PropertyDefinition.CreateBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDefinition
的用法示例。
在下文中一共展示了PropertyDefinition.CreateBinding方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCheckBoxControl
/// <summary>
/// Creates the check box control.
/// </summary>
/// <param name="property">The property.</param>
/// <returns></returns>
protected virtual FrameworkElement CreateCheckBoxControl(PropertyDefinition property)
{
var c = new CheckBox { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = property.HorizontalAlignment };
c.SetBinding(ToggleButton.IsCheckedProperty, property.CreateBinding());
return c;
}
示例2: CreateTextBox
/// <summary>
/// Creates the text box.
/// </summary>
/// <param name="d">The d.</param>
/// <returns></returns>
protected virtual FrameworkElement CreateTextBox(PropertyDefinition d)
{
var tb = new TextBox
{
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = d.HorizontalAlignment,
MaxLength = d.MaxLength,
BorderThickness = new Thickness(0),
Margin = new Thickness(1, 1, 0, 0)
};
tb.SetBinding(TextBox.TextProperty, d.CreateBinding());
return tb;
}
示例3: CreateComboBox
/// <summary>
/// Creates the combo box.
/// </summary>
/// <param name="d">The d.</param>
/// <returns></returns>
protected virtual FrameworkElement CreateComboBox(PropertyDefinition d)
{
var c = new ComboBox { IsEditable = d.IsEditable, Focusable = false, Margin = new Thickness(0, 0, -1, -1) };
if (d.ItemsSource != null)
c.ItemsSource = d.ItemsSource;
else
{
if (d.ItemsSourceProperty != null) c.SetBinding(ItemsControl.ItemsSourceProperty, new Binding(d.ItemsSourceProperty));
}
c.SetBinding(d.IsEditable ? ComboBox.TextProperty : Selector.SelectedValueProperty, d.CreateBinding());
return c;
}
示例4: CreateColorPreviewControl
protected virtual FrameworkElement CreateColorPreviewControl(PropertyDefinition property)
{
var c = new Rectangle
{
Stroke = Brushes.Black,
StrokeThickness = 1,
Width = 12,
Height = 12,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center
};
property.Converter = new ColorToBrushConverter();
c.SetBinding(Shape.FillProperty, property.CreateBinding());
return c;
}
示例5: CreateColorPickerControl
/// <summary>
/// Creates the color picker control.
/// </summary>
/// <param name="property">The property.</param>
/// <returns></returns>
protected virtual FrameworkElement CreateColorPickerControl(PropertyDefinition property)
{
var c = new ColorPicker2 { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch };
c.SetBinding(ColorPicker2.SelectedColorProperty, property.CreateBinding());
return c;
}
示例6: CreateExtendedToolkitControl
public FrameworkElement CreateExtendedToolkitControl(PropertyDefinition propertyDefinition, string bindingPath)
{
var propertyType = propertyDefinition.PropertyType;
if (propertyType.Is(typeof(DateTime)))
{
var c = new DateTimePicker()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(DateTimePicker.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(TimeSpan)))
{
var c = new TimeSpanUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(TimeSpanUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(int)) || propertyType.Is(typeof(int?)))
{
var c = new CalculatorUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
Minimum = int.MinValue,
Maximum = int.MaxValue,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(uint)) || propertyType.Is(typeof(uint?)))
{
var c = new CalculatorUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
Minimum = 0,
Maximum = uint.MaxValue,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(decimal)) || propertyType.Is(typeof(decimal?)))
{
var c = new CalculatorUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
Minimum = decimal.MinValue,
Maximum = decimal.MaxValue,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(Single)) || propertyType.Is(typeof(Single?)))
{
var c = new CalculatorUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
Minimum = decimal.MinValue,
Maximum = decimal.MaxValue,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(double)) || propertyType.Is(typeof(double?)))
{
var c = new CalculatorUpDown()
{
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Stretch,
Minimum = decimal.MinValue,
Maximum = decimal.MaxValue,
IsReadOnly = propertyDefinition.IsReadOnly
};
c.SetBinding(CalculatorUpDown.ValueProperty, propertyDefinition.CreateBinding(bindingPath));
return c;
}
if (propertyType.Is(typeof(Brush)))
{
var c = new ColorBox.ColorBox()
//.........这里部分代码省略.........