当前位置: 首页>>代码示例>>C#>>正文


C# INotifyPropertyChanged.GetProperty方法代码示例

本文整理汇总了C#中INotifyPropertyChanged.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# INotifyPropertyChanged.GetProperty方法的具体用法?C# INotifyPropertyChanged.GetProperty怎么用?C# INotifyPropertyChanged.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在INotifyPropertyChanged的用法示例。


在下文中一共展示了INotifyPropertyChanged.GetProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bind

        public static PropertyChangedEventHandler Bind(this SeekBar seekBar, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            var r = property.GetCustomAttribute<RangeAttribute> ();

            if (r != null)
            {
                seekBar.Max = (int)r.Maximum;
            }

            var handler = new PropertyChangedEventHandler ((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                        //textField.SetText(source, property);
                    }
                });

            source.PropertyChanged += handler;

            //textField.AfterTextChanged += (sender, e) => property.GetSetMethod().Invoke(source, new []{textField.Text});

            return handler;
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:25,代码来源:SeekBarExtensions.cs

示例2: Bind

        public static PropertyChangedEventHandler Bind(this CompoundButton toggle, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            if (property.PropertyType == typeof(bool))
            {
                toggle.SetValue(source, property);
                var handler = new PropertyChangedEventHandler ((s, e) =>
                    {
                        if (e.PropertyName == propertyName)
                        {
                            var activity = toggle.Context as Activity;

                            if (activity != null)
                            {
                                activity.RunOnUiThread(() => toggle.SetValue(source, property));
                            }
                        }
                    });

                source.PropertyChanged += handler;
                toggle.CheckedChange += (sender, e) => property.GetSetMethod().Invoke (source, new object[]{ toggle.Checked });

                return handler;
            } 
            else
            {
                throw new InvalidCastException ("Binding property is not boolean");
            }
        }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:30,代码来源:CompoundButtonExtensions.cs

示例3: Bind

        public static Action Bind(this UISwitch toggle, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            if (property.PropertyType == typeof(bool))
            {
                toggle.SetValue(source, property);
                var handler = new PropertyChangedEventHandler ((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                            toggle.InvokeOnMainThread(()=>
                                toggle.SetValue(source, property));
                    }
                });

                source.PropertyChanged += handler;

                var valueChanged = new EventHandler(
                    (sender, e) => property.GetSetMethod().Invoke (source, new object[]{ toggle.On }));

                toggle.ValueChanged += valueChanged;

                return new Action(() =>
                {
                    source.PropertyChanged -= handler;
                    toggle.ValueChanged -= valueChanged;
                });
            } 
            else
            {
                throw new InvalidCastException ("Binding property is not boolean");
            }
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:34,代码来源:SwitchExtensions.cs

示例4: Bind

        public static PropertyChangedEventHandler Bind(this EditText textField, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            textField.SetText(source, property);

            var handler = new PropertyChangedEventHandler ((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                        var activity = textField.Context as Activity;

                        if (activity != null)
                        {
                            activity.RunOnUiThread(() => textField.SetText(source, property));
                        }
                    }
                });

            source.PropertyChanged += handler;

            textField.AfterTextChanged += (sender, e) => property.GetSetMethod().Invoke(source, new []{textField.Text});

            return handler;
        }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:25,代码来源:EditTextExtensions.cs

示例5: Bind

        public static Action Bind(this UITextField textField, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            textField.SetText(source, property);
            var handler = new PropertyChangedEventHandler((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                        textField.InvokeOnMainThread(()=>
                            textField.SetText(source, property));
                    }
                });

            source.PropertyChanged += handler;

            var editHandler = new EventHandler((s, e) =>
                {
                    var sender = s as UITextField;
                    if (sender != null)
                    {
                        property.GetSetMethod().Invoke(source, new[] { sender.Text });
                    }
                });

            textField.EditingChanged += editHandler;

            // create an action to remove the event handlers
            return new Action(() =>
                {
                    textField.EditingChanged -= editHandler;
                    source.PropertyChanged -= handler;
                });
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:34,代码来源:TextFieldExtensions.cs

示例6: BindTitle

        public static void BindTitle(this Button button, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            button.SetTitle (source, property);

            source.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == propertyName)
                {
                    var activity = button.Context as Activity;

                    if (activity != null)
                    {
                        activity.RunOnUiThread(() => button.SetTitle(source, property));
                    }
                }
            };
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:19,代码来源:ButtonExtensions.cs

示例7: BindTitle

        public static Action BindTitle(this UIButton button, 
                    INotifyPropertyChanged source, 
                    string propertyName,
                    UIControlState state = UIControlState.Normal)
        {
            var property = source.GetProperty(propertyName);

            button.SetTitle (source, property, state);

            var handler = new PropertyChangedEventHandler(
                (s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                        button.SetTitle (source, property, state);
                    }
                }
            );

            source.PropertyChanged += handler;

            return new Action(() => source.PropertyChanged -= handler);
        }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:23,代码来源:ButtonExtensions.cs

示例8: Bind

        public static Action Bind(
            this UILabel label, 
            INotifyPropertyChanged source, 
            string propertyName, 
            IFormatProvider formatProvider = null)
        {
            var property = source.GetProperty(propertyName);

            var l = new WeakReference<UILabel> (label);
            label.SetText(source, property);

            var handler = new PropertyChangedEventHandler((s, e) =>
            {
                UILabel weakRef;
                if (e.PropertyName == propertyName && l.TryGetTarget(out weakRef))
                {
                    weakRef.InvokeOnMainThread(()=> weakRef.SetText(source, property));
                }
            });

            source.PropertyChanged += handler;

            return new Action(() => source.PropertyChanged -= handler);
        }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:24,代码来源:LabelExtensions.cs

示例9: GetProperty

        private static PropertyInfo GetProperty(INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            if (property.PropertyType == typeof(int) || property.PropertyType == typeof(double)
                || property.PropertyType == typeof(float))
            {
                return property;
            }

            throw new InvalidCastException ("Binding property is not valid");
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:12,代码来源:SliderExtensions.cs


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