本文整理汇总了C#中System.Windows.FrameworkElement.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.SetBinding方法的具体用法?C# FrameworkElement.SetBinding怎么用?C# FrameworkElement.SetBinding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBindingObject
public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
{
Type propertyType = source.GetType().GetProperty(propertyName).PropertyType;
PropertyInfo info = source.GetType().GetProperty("RangeList");
FANumberRangeRule rangeRule = null;
if (info != null)
{
object value = info.GetValue(source, null);
if (value != null)
{
FALibrary.Utility.SerializableDictionary<string, FARange> dic =
(FALibrary.Utility.SerializableDictionary<string, FARange>)value;
if (dic.ContainsKey(propertyName))
{
rangeRule = new FANumberRangeRule(propertyType);
rangeRule.Range = dic[propertyName];
obj.Tag = rangeRule;
obj.Style = (Style)App.Current.Resources["TextBoxErrorStyle"];
}
}
}
Binding bd = new Binding(propertyName);
bd.Source = source;
bd.Mode = mode;
bd.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
if (rangeRule != null)
{
bd.NotifyOnValidationError = true;
bd.ValidationRules.Add(rangeRule);
}
obj.SetBinding(dp, bd);
}
示例2: SetBindings
public override void SetBindings(DesignItem item, FrameworkElement view)
{
base.SetBindings(item, view);
view.SetBinding(FrameworkElement.VerticalAlignmentProperty, new Binding("Component.VerticalOptions") { Source = item, Converter = LayoutOptionsToVerticalAlignmentConverter.Instance });
view.SetBinding(FrameworkElement.HorizontalAlignmentProperty, new Binding("Component.HorizontalOptions") { Source = item, Converter = LayoutOptionsToHorizontalAlignmentConverter.Instance });
}
示例3: EditableFrameworkElement
internal EditableFrameworkElement(CanvasEditor editor, FrameworkElement element)
{
Editor = editor;
UIElement = element;
Position = new PointNotifyPropertyChanged(new Point(
(double)element.GetValue(Canvas.LeftProperty),
(double)element.GetValue(Canvas.TopProperty)));
Size = new SizeNotifyPropertyChanged(new Size(
(double)element.GetValue(Canvas.WidthProperty),
(double)element.GetValue(Canvas.HeightProperty)));
Binding xBinding = new Binding(PointNotifyPropertyChanged.XProperty);
xBinding.Source = Position;
element.SetBinding(Canvas.LeftProperty, xBinding);
Binding yBinding = new Binding(PointNotifyPropertyChanged.YProperty);
yBinding.Source = Position;
element.SetBinding(Canvas.TopProperty, yBinding);
Binding wBinding = new Binding(SizeNotifyPropertyChanged.WidthProperty);
wBinding.Source = Size;
element.SetBinding(Canvas.WidthProperty, wBinding);
Binding hBinding = new Binding(SizeNotifyPropertyChanged.HeightProperty);
hBinding.Source = Size;
element.SetBinding(Canvas.HeightProperty, hBinding);
Position.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Position_PropertyChanged);
Size.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Size_PropertyChanged);
}
示例4: SetBindings
public override void SetBindings(DesignItem item, FrameworkElement view)
{
base.SetBindings(item, view);
view.SetBinding(EntryView.TextProperty, new Binding("Component.Text") { Source = item });
view.SetBinding(EntryView.VisibilityProperty, new Binding("Component.IsVisible") { Source = item, Converter = IsVisibleToVisibilityConverter.Instance });
view.SetBinding(EntryView.FontSizeProperty, new Binding("Component.FontSize") { Source = item });
view.SetBinding(EntryView.ForegroundProperty, new Binding("Component.TextColor") { Source = item, Converter = ColorToBrushConverter.Instance });
}
示例5: SetCommonBindings
protected override void SetCommonBindings(FrameworkElement marker)
{
base.SetCommonBindings(marker);
marker.SetValue(ViewportPanel.YProperty, 0.0);
marker.SetBinding(ViewportPanel.ViewportHeightProperty, DependentValueBinding);
marker.SetBinding(ViewportPanel.ViewportWidthProperty, ColumnWidthBinding);
marker.SetValue(ViewportPanel.ViewportVerticalAlignmentProperty, VerticalAlignment.Bottom);
marker.SetBinding(ViewportPanel.XProperty, IndexBinding);
}
示例6: AddCommonBindings
protected override void AddCommonBindings(FrameworkElement marker)
{
base.AddCommonBindings(marker);
marker.SetValue(ViewportPanel.XProperty, 0.0);
marker.SetBinding(ViewportPanel.ViewportWidthProperty, viewportWidthBinding);
marker.SetValue(ViewportPanel.ViewportHeightProperty, 0.85);
marker.SetValue(ViewportPanel.ViewportHorizontalAlignmentProperty, HorizontalAlignment.Left);
marker.SetBinding(ViewportPanel.YProperty, viewportYBinding);
}
示例7: SetBindingObject
public static void SetBindingObject(FrameworkElement obj, BindingMode mode, object source, DependencyProperty dp, string propertyName)
{
Binding bd = new Binding(propertyName);
bd.Source = source;
bd.Mode = mode;
obj.SetBinding(dp, bd);
}
示例8: ReplaceContent
/// <summary>
/// Replaces the content for a <see cref="DataField"/> with another control and updates the bindings.
/// </summary>
/// <param name="field">The <see cref="DataField"/> whose <see cref="TextBox"/> will be replaced.</param>
/// <param name="newControl">The new control you're going to set as <see cref="DataField.Content" />.</param>
/// <param name="dataBindingProperty">The control's property that will be used for data binding.</param>
/// <param name="bindingSetupFunction">
/// An optional <see cref="Action"/> you can use to change parameters on the newly generated binding before
/// it is applied to <paramref name="newControl"/>
/// </param>
/// <param name="sourceProperty">The source dependency property to use for the binding.</param>
public static void ReplaceContent(this DataField field, FrameworkElement newControl, DependencyProperty dataBindingProperty, Action<Binding> bindingSetupFunction, DependencyProperty sourceProperty)
{
if (field == null)
{
throw new ArgumentNullException("field");
}
if (newControl == null)
{
throw new ArgumentNullException("newControl");
}
// Construct new binding by copying existing one, and sending it to bindingSetupFunction
// for any changes the caller wants to perform
Binding newBinding = field.Content.GetBindingExpression(sourceProperty).ParentBinding.CreateCopy();
if (bindingSetupFunction != null)
{
bindingSetupFunction(newBinding);
}
// Replace field
newControl.SetBinding(dataBindingProperty, newBinding);
field.Content = newControl;
}
示例9: BindProperty
public static void BindProperty(FrameworkElement element, object source,
string path, DependencyProperty property, BindingMode mode)
{
var binding = new Binding(path);
binding.Source = source;
binding.Mode = mode;
element.SetBinding(property, binding);
}
示例10: Bind
public static void Bind(object dataSource, string sourcePath, FrameworkElement destinationObject, DependencyProperty dp)
{
Binding binding = new Binding();
binding.Source = dataSource;
binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
binding.Path = new PropertyPath(sourcePath);
destinationObject.SetBinding(dp, binding);
}
示例11: RegisterForNotification
public static void RegisterForNotification(string property, FrameworkElement frameworkElement, PropertyChangedCallback OnCallBack)
{
Binding binding2 = new Binding(property);
binding2.set_Source(frameworkElement);
Binding binding = binding2;
DependencyProperty property2 = DependencyProperty.RegisterAttached("ListenAttached" + property, typeof(object), typeof(UserControl), new PropertyMetadata(OnCallBack));
frameworkElement.SetBinding(property2, binding);
}
示例12: AmplitudeModulate
public static Oscillator AmplitudeModulate(this Oscillator oscillator, FrameworkElement target, DependencyProperty property)
{
Binding frequencyBinding = new Binding();
frequencyBinding.Mode = BindingMode.TwoWay;
frequencyBinding.Source = oscillator.AmplitudeModulator;
frequencyBinding.Path = new PropertyPath("ModulationFrequency");
target.SetBinding(property, frequencyBinding);
return oscillator;
}
示例13: AddCommonBindings
protected override void AddCommonBindings(FrameworkElement marker)
{
base.AddCommonBindings(marker);
marker.SetValue(ViewportPanel.YProperty, 0.0);
if (!String.IsNullOrEmpty(DependentValuePath))
{
viewportHeightBinding = new Binding(DependentValuePath);
}
marker.SetBinding(ViewportPanel.ViewportHeightProperty, viewportHeightBinding);
if (ViewportPanel.GetViewportWidth(marker).IsNaN())
marker.SetValue(ViewportPanel.ViewportWidthProperty, 0.85);
marker.SetValue(ViewportPanel.ViewportVerticalAlignmentProperty, VerticalAlignment.Bottom);
marker.SetBinding(ViewportPanel.XProperty, viewportXBinding);
}
示例14: Attenuate
public static Attenuator Attenuate(this Mixer mixer, FrameworkElement target, DependencyProperty property)
{
Attenuator attenuator = new Attenuator() { Input = mixer };
Binding binding = new Binding();
binding.Mode = BindingMode.TwoWay;
binding.Source = attenuator;
binding.Path = new PropertyPath("Attenuation");
target.SetBinding(property, binding);
return attenuator;
}
示例15: BindProperty
public static void BindProperty(FrameworkElement element, BindableProperty property)
{
Guard.ArgumentNotNull(element, "element");
var enabledBinding = new Binding("ReadOnly");
enabledBinding.Converter = new BooleanInverseConverter();
enabledBinding.Source = property;
element.SetBinding(UIElement.IsEnabledProperty, enabledBinding);
}