• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# PerspexProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PerspexProperty的典型用法代码示例。如果您正苦于以下问题:C# PerspexProperty类的具体用法?C# PerspexProperty怎么用?C# PerspexProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PerspexProperty类属于命名空间,在下文中一共展示了PerspexProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:hacklex,项目名称:Perspex,代码行数:29,代码来源:XamlBinding.cs


示例2: XamlBindingDefinition

 public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
 {
     this.target = target;
     this.targetProperty = targetProperty;
     this.sourcePropertyPath = sourcePropertyPath;
     this.bindingMode = bindingMode;
 }
开发者ID:Scellow,项目名称:Perspex,代码行数:7,代码来源:XamlBindingDefinition.cs


示例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;
            }
        }
开发者ID:hacklex,项目名称:Perspex,代码行数:25,代码来源:XamlBinding.cs


示例4: XamlBindingDefinition

 public XamlBindingDefinition(Control target, PerspexProperty targetProperty, PropertyPath sourcePropertyPath, BindingMode bindingMode)
 {
     _target = target;
     _targetProperty = targetProperty;
     _sourcePropertyPath = sourcePropertyPath;
     _bindingMode = bindingMode;
 }
开发者ID:healtech,项目名称:Perspex,代码行数:7,代码来源:XamlBindingDefinition.cs


示例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;
     }
 }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:14,代码来源:PropertyMetadata.cs


示例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);
            }
        }
开发者ID:abdelkarim,项目名称:Perspex,代码行数:14,代码来源:MultiBinding.cs


示例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);
            }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:9,代码来源:PerspexPropertyAccessorPlugin.cs


示例8: Bind

        public void Bind(IObservablePropertyBag instance, PerspexProperty property)
        {
            var subject = CreateSubject(instance, property);

            if (subject != null)
            {
                Bind(instance, property, subject);
            }
        }
开发者ID:strogo,项目名称:Perspex,代码行数:9,代码来源:MultiBinding.cs


示例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;
 }
开发者ID:Scellow,项目名称:Perspex,代码行数:18,代码来源:PerspexPropertyValue.cs


示例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);
            }
        }
开发者ID:JackWangCUMT,项目名称:Perspex,代码行数:17,代码来源:Binding.cs


示例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>());
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:12,代码来源:PerspexPropertyTests.cs


示例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()}");
     }
 }
开发者ID:alimbada,项目名称:Perspex,代码行数:12,代码来源:PropertyAccessor.cs


示例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;
 }
开发者ID:Robertofon,项目名称:Perspex,代码行数:21,代码来源:PerspexPropertyChangedEventArgs.cs


示例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);
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:13,代码来源:DataContextChangeSynchronizer.cs


示例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>());
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:14,代码来源:PerspexPropertyTests.cs


示例16: CreateSubject

        /// <summary>
        /// Creates a subject that can be used to get and set the value of the binding.
        /// </summary>
        /// <param name="target">The target instance.</param>
        /// <param name="targetProperty">The target property.</param>
        /// <returns>An <see cref="ISubject{Object}"/>.</returns>
        public ISubject<object> CreateSubject(IPerspexObject target, PerspexProperty targetProperty)
        {
            if (Converter == null)
            {
                throw new NotSupportedException("MultiBinding without Converter not currently supported.");
            }

            var targetType = targetProperty?.PropertyType ?? typeof(object);
            var result = new BehaviorSubject<object>(PerspexProperty.UnsetValue);
            var children = Bindings.Select(x => x.CreateSubject(target, null));
            var input = children.CombineLatest().Select(x => ConvertValue(x, targetType));
            input.Subscribe(result);
            return result;
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:20,代码来源:MultiBinding.cs


示例17: Constructor_Sets_Properties

        public void Constructor_Sets_Properties()
        {
            PerspexProperty<string> target = new PerspexProperty<string>(
                "test",
                typeof(Class1),
                "Foo",
                false,
                BindingMode.OneWay,
                null);

            Assert.Equal("test", target.Name);
            Assert.Equal(typeof(string), target.PropertyType);
            Assert.Equal(typeof(Class1), target.OwnerType);
            Assert.Equal(false, target.Inherits);
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:15,代码来源:PerspexPropertyTests.cs


示例18: 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)
        {
            Contract.Requires<ArgumentNullException>(instance != null);
            Contract.Requires<ArgumentNullException>(property != null);

            var subject = CreateSubject(
                instance,
                property.PropertyType,
                property == Control.DataContextProperty);

            if (subject != null)
            {
                Bind(instance, property, subject);
            }
        }
开发者ID:Sergey-Terekhin,项目名称:Perspex,代码行数:20,代码来源:Binding.cs


示例19: CreateSubject

        public ISubject<object> CreateSubject(
            IObservablePropertyBag instance, 
            PerspexProperty property)
        {
            if (Converter == null)
            {
                throw new NotSupportedException("MultiBinding without Converter not currently supported.");
            }

            var result = new Subject<object>();
            var children = Bindings.Select(x => x.CreateExpressionSubject(instance, property));
            var input = Observable.CombineLatest(children).Select(x =>
                Converter.Convert(x, property.PropertyType, null, CultureInfo.CurrentUICulture));
            input.Subscribe(result);
            return result;
        }
开发者ID:strogo,项目名称:Perspex,代码行数:16,代码来源:MultiBinding.cs


示例20: CreateSubject

        /// <summary>
        /// Creates a subject that can be used to get and set the value of the binding.
        /// </summary>
        /// <param name="target">The target instance.</param>
        /// <param name="targetProperty">The target property. May be null.</param>
        /// <returns>An <see cref="ISubject{Object}"/>.</returns>
        public ISubject<object> CreateSubject(
            IPerspexObject target, 
            PerspexProperty targetProperty)
        {
            Contract.Requires<ArgumentNullException>(target != null);

            var pathInfo = ParsePath(Path);
            ValidateState(pathInfo);

            ExpressionObserver observer;

            if (pathInfo.ElementName != null || ElementName != null)
            {
                observer = CreateElementObserver(
                    (IControl)target, 
                    pathInfo.ElementName ?? ElementName, 
                    pathInfo.Path);
            }
            else if (Source != null)
            {
                observer = CreateSourceObserver(Source, pathInfo.Path);
            }
            else if (RelativeSource == null || RelativeSource.Mode == RelativeSourceMode.DataContext)
            {
                observer = CreateDataContexObserver(
                    target, 
                    pathInfo.Path,
                    targetProperty == Control.DataContextProperty);
            }
            else if (RelativeSource.Mode == RelativeSourceMode.TemplatedParent)
            {
                observer = CreateTemplatedParentObserver(target, pathInfo.Path);
            }
            else
            {
                throw new NotSupportedException();
            }

            return new ExpressionSubject(
                observer,
                targetProperty?.PropertyType ?? typeof(object),
                Converter ?? DefaultValueConverter.Instance,
                ConverterParameter,
                FallbackValue);
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:51,代码来源:Binding.cs



注:本文中的PerspexProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PerspexPropertyChangedEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# PersonalizationScope类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap