本文整理汇总了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;
}
示例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");
}
}
示例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");
}
}
示例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;
}
示例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;
});
}
示例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));
}
}
};
}
示例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);
}
示例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);
}
示例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");
}