本文整理汇总了C#中PerspexProperty类的典型用法代码示例。如果您正苦于以下问题:C# PerspexProperty类的具体用法?C# PerspexProperty怎么用?C# PerspexProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PerspexProperty类属于命名空间,在下文中一共展示了PerspexProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateExpressionObserver
public ExpressionObserver CreateExpressionObserver(
IObservablePropertyBag instance,
PerspexProperty property)
{
IObservable<object> dataContext = null;
if (property != Control.DataContextProperty)
{
dataContext = instance.GetObservable(Control.DataContextProperty);
}
else
{
var parent = instance.InheritanceParent as IObservablePropertyBag;
if (parent != null)
{
dataContext = parent.GetObservable(Control.DataContextProperty);
}
}
if (dataContext != null)
{
var result = new ExpressionObserver(null, SourcePropertyPath);
dataContext.Subscribe(x => result.Root = x);
return result;
}
return null;
}
示例2: XamlBindingDefinition
public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
{
this.target = target;
this.targetProperty = targetProperty;
this.sourcePropertyPath = sourcePropertyPath;
this.bindingMode = bindingMode;
}
示例3: Bind
internal void Bind(IObservablePropertyBag target, PerspexProperty property, ISubject<object> subject)
{
var mode = BindingMode == BindingMode.Default ?
property.DefaultBindingMode : BindingMode;
switch (mode)
{
case BindingMode.Default:
case BindingMode.OneWay:
target.Bind(property, subject);
break;
case BindingMode.TwoWay:
target.BindTwoWay(property, subject);
break;
case BindingMode.OneTime:
target.GetObservable(Control.DataContextProperty).Subscribe(dataContext =>
{
subject.Take(1).Subscribe(x => target.SetValue(property, x));
});
break;
case BindingMode.OneWayToSource:
target.GetObservable(property).Subscribe(subject);
break;
}
}
示例4: XamlBindingDefinition
public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
{
_target = target;
_targetProperty = targetProperty;
_sourcePropertyPath = sourcePropertyPath;
_bindingMode = bindingMode;
}
示例5: Merge
/// <summary>
/// Merges the metadata with the base metadata.
/// </summary>
/// <param name="baseMetadata">The base metadata to merge.</param>
/// <param name="property">The property to which the metadata is being applied.</param>
public virtual void Merge(
PropertyMetadata baseMetadata,
PerspexProperty property)
{
if (_defaultBindingMode == BindingMode.Default)
{
_defaultBindingMode = baseMetadata.DefaultBindingMode;
}
}
示例6: Bind
/// <summary>
/// Applies the binding to a property on an instance.
/// </summary>
/// <param name="instance">The target instance.</param>
/// <param name="property">The target property.</param>
public void Bind(IPerspexObject instance, PerspexProperty property)
{
var subject = CreateSubject(instance, property);
if (subject != null)
{
Bind(instance, property, subject);
}
}
示例7: Accessor
public Accessor(PerspexObject instance, PerspexProperty property, Action<object> changed)
{
Contract.Requires<ArgumentNullException>(instance != null);
Contract.Requires<ArgumentNullException>(property != null);
_instance = instance;
_property = property;
_subscription = instance.GetObservable(property).Skip(1).Subscribe(changed);
}
示例8: Bind
public void Bind(IObservablePropertyBag instance, PerspexProperty property)
{
var subject = CreateSubject(instance, property);
if (subject != null)
{
Bind(instance, property, subject);
}
}
示例9: PerspexPropertyValue
/// <summary>
/// Initializes a new instance of the <see cref="PerspexPropertyValue"/> class.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="value">The current property value.</param>
/// <param name="priority">The priority of the current value.</param>
/// <param name="diagnostic">A diagnostic string.</param>
public PerspexPropertyValue(
PerspexProperty property,
object value,
BindingPriority priority,
string diagnostic)
{
this.Property = property;
this.Value = value;
this.Priority = priority;
this.Diagnostic = diagnostic;
}
示例10: Bind
/// <summary>
/// Applies the binding to a property on an instance.
/// </summary>
/// <param name="instance">The target instance.</param>
/// <param name="property">The target property.</param>
public void Bind(IObservablePropertyBag instance, PerspexProperty property)
{
var subject = CreateSubject(
instance,
property.PropertyType,
property == Control.DataContextProperty);
if (subject != null)
{
Bind(instance, property, subject);
}
}
示例11: GetDefaultValue_Returns_Registered_Value_For_Not_Overridden_Class
public void GetDefaultValue_Returns_Registered_Value_For_Not_Overridden_Class()
{
PerspexProperty<string> target = new PerspexProperty<string>(
"test",
typeof(Class1),
"Foo",
false,
BindingMode.OneWay,
null);
Assert.Equal("Foo", target.GetDefaultValue<Class2>());
}
示例12: SetBinding
private static void SetBinding(
object instance,
MutableMember member,
PerspexProperty property,
IBinding binding)
{
if (!(AssignBinding(instance, member, binding) || ApplyBinding(instance, property, binding)))
{
throw new InvalidOperationException(
$"Cannot assign to '{member.Name}' on '{instance.GetType()}");
}
}
示例13: PerspexPropertyChangedEventArgs
/// <summary>
/// Initializes a new instance of the <see cref="PerspexPropertyChangedEventArgs"/> class.
/// </summary>
/// <param name="sender">The object that the property changed on.</param>
/// <param name="property">The property that changed.</param>
/// <param name="oldValue">The old value of the property.</param>
/// <param name="newValue">The new value of the property.</param>
/// <param name="priority">The priority of the binding that produced the value.</param>
public PerspexPropertyChangedEventArgs(
PerspexObject sender,
PerspexProperty property,
object oldValue,
object newValue,
BindingPriority priority)
{
this.Sender = sender;
this.Property = property;
this.OldValue = oldValue;
this.NewValue = newValue;
this.Priority = priority;
}
示例14: DataContextChangeSynchronizer
public DataContextChangeSynchronizer(PerspexObject target, PerspexProperty targetProperty,
PropertyPath sourcePropertyPath, object source, ITypeConverterProvider typeConverterProvider)
{
Guard.ThrowIfNull(target, nameof(target));
Guard.ThrowIfNull(targetProperty, nameof(targetProperty));
Guard.ThrowIfNull(sourcePropertyPath, nameof(sourcePropertyPath));
Guard.ThrowIfNull(source, nameof(source));
Guard.ThrowIfNull(typeConverterProvider, nameof(typeConverterProvider));
this.bindingEndpoint = new TargetBindingEndpoint(target, targetProperty);
this.sourceEndpoint = new ObservablePropertyBranch(source, sourcePropertyPath);
this.targetPropertyTypeConverter = typeConverterProvider.GetTypeConverter(targetProperty.PropertyType);
}
示例15: GetDefaultValue_Returns_Overridden_Value
public void GetDefaultValue_Returns_Overridden_Value()
{
PerspexProperty<string> target = new PerspexProperty<string>(
"test",
typeof(Class1),
"Foo",
false,
BindingMode.OneWay,
null);
target.OverrideDefaultValue(typeof(Class2), "Bar");
Assert.Equal("Bar", target.GetDefaultValue<Class2>());
}