本文整理汇总了C#中BindableObject类的典型用法代码示例。如果您正苦于以下问题:C# BindableObject类的具体用法?C# BindableObject怎么用?C# BindableObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BindableObject类属于命名空间,在下文中一共展示了BindableObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemsSourcePropertyChanged
private static void ItemsSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var articles = newValue as IEnumerable;
var galery = bindable as ArticleCarouselView;
if (galery != null)
{
if (articles != null)
{
foreach (var article in articles)
{
try
{
galery.BatchBegin();
galery.Children.Add(new BigArticleView {BindingContext = article});
galery.BatchCommit();
}
catch
{
}
}
}
else
{
try
{
galery.Children.Clear();
}
catch
{
}
}
}
}
示例2: ItemsSourceChanged
private static void ItemsSourceChanged(BindableObject bindable, IEnumerable oldValue, IEnumerable newValue) {
var picker = (Picker)bindable;
if (picker == null)
throw new Exception("only support Picker");
var selected = picker.SelectedIndex;
var type = newValue.GetType().GenericTypeArguments[0].GetTypeInfo();
var dp = (string)bindable.GetValue(DisplayPathProperty);
PropertyInfo p = null;
if (!string.IsNullOrWhiteSpace(dp)) {
p = type.GetDeclaredProperty(dp);
}
foreach (var o in newValue) {
object value = null;
if (p != null)
value = p.GetValue(o);
else
value = o;
if (value != null)
picker.Items.Add(value.ToString());
}
picker.SelectedIndex = selected;
}
示例3: OnSelectTemplate
protected override DataTemplate OnSelectTemplate(object item, int columnIndex, BindableObject container)
{
if (columnIndex == 0)
return _leftTemplate;
return _rightTemplate;
}
示例4: OnItemsSourceChanged
private static void OnItemsSourceChanged(BindableObject bindable, IEnumerable oldvalue, IEnumerable newvalue)
{
var radButtons = bindable as BindableRadioGroup;
radButtons.rads.Clear();
radButtons.Children.Clear();
if (newvalue != null)
{
int radIndex = 0;
foreach (var item in newvalue)
{
var rad = new CustomRadioButton();
rad.Text = item.ToString();
rad.Id = radIndex;
rad.CheckedChanged += radButtons.OnCheckedChanged;
radButtons.rads.Add(rad);
radButtons.Children.Add(rad);
radIndex++;
}
}
}
示例5: IsShowAnimChanged
private static void IsShowAnimChanged(BindableObject bindable, bool oldvalue, bool newvalue)
{
var control = bindable as SkypeAnimControl;
if(control == null) return;
control.IsShowAnim = newvalue;
control.ShowAnimEvent?.Invoke(control, new EventArgs());
}
示例6: VMChanged
private static void VMChanged(BindableObject bindable, object oldValue, object newValue)
{
if (newValue == null)
return;
var vm = (Screen)newValue;
//var view = vm.GetView();
var vmView = ViewLocator.LocateForModel(vm, null, null);
if (vmView == null)
throw new Exception("没有找到视图");
ViewModelBinder.Bind(vm, vmView, null);
var activator = vm as IActivate;
if (activator != null)
activator.Activate();
var page = (ViewLocatorPage)bindable;
if (null != (ContentPage)vmView) {
var vp = (ContentPage)vmView;
page.Content = vp.Content;
if (vp.ToolbarItems != null)
foreach (var t in vp.ToolbarItems)
page.ToolbarItems.Add(t);
} else if (null != (Xamarin.Forms.View)vmView) {
page.Content = (Xamarin.Forms.View)vmView;
}
}
示例7: UpdateTexts
static void UpdateTexts(BindableObject bindable, string oldValue, string newValue)
{
var instance = bindable as Bz29300DummyView;
instance.Children.Clear();
for (int i = 0; i < instance.NumOfRepeat; i++)
instance.Children.Add(new Label() {Text = newValue });
}
示例8: MergedStyle
public MergedStyle(Type targetType, BindableObject target)
{
Target = target;
TargetType = targetType;
RegisterImplicitStyles();
Apply(Target);
}
示例9: OnItemsSourceChanged
// void UpdateSelected()
// {
// if (ItemsSource != null)
// {
// if (ItemsSource.Contains(SelectedItem))
// {
// SelectedIndex = ItemsSource.IndexOf(SelectedItem);
// }
// else
// {
// SelectedIndex = -1;
// }
// }
// }
static void OnItemsSourceChanged(BindableObject bindable, IList oldvalue, IList newvalue)
{
var picker = bindable as BindablePicker;
if (picker != null)
{
picker.Items.Clear();
if (newvalue == null) return;
//now it works like "subscribe once" but you can improve
foreach (var item in newvalue)
{
if (string.IsNullOrEmpty(picker.DisplayMember))
{
picker.Items.Add(item.ToString());
}
else
{
var type = item.GetType();
var prop = type.GetProperty(picker.DisplayMember);
picker.Items.Add(prop.GetValue(item).ToString());
}
}
}
}
示例10: AccessoryButtonsPropertyChanging
private static void AccessoryButtonsPropertyChanging(BindableObject bindable, object oldvalue,
object newvalue)
{
var oldList = oldvalue as List<ToolBarButton>;
if (oldList != null)
{
foreach (var button in oldList)
button.BindingContext = null;
}
var oldObs = oldvalue as INotifyCollectionChanged;
if (oldObs != null)
oldObs.CollectionChanged -= ((ToolBar)bindable).ButtonsOnCollectionChanged;
var newList = newvalue as List<ToolBarButton>;
if (newList != null)
{
var entry = (ExtendedEntry)bindable;
foreach (var button in newList)
button.BindingContext = entry.BindingContext;
}
var newObs = newvalue as INotifyCollectionChanged;
if (newObs != null)
newObs.CollectionChanged += ((ToolBar)bindable).ButtonsOnCollectionChanged;
}
示例11: ApplyStyle
private static void ApplyStyle(BindableObject bindable, Style newvalue)
{
foreach (var setter in newvalue.Setters )
{
bindable.SetValue(setter.Property, setter.Value);
}
}
示例12: SelectTemplate
/// <summary>
/// Selects the template.
/// </summary>
/// <returns>The template.</returns>
/// <param name="item">Item.</param>
/// <param name="columnIndex">Column index.</param>
/// <param name="container">Container.</param>
public DataTemplate SelectTemplate(object item, int columnIndex, BindableObject container)
{
DataTemplate result = OnSelectTemplate(item, columnIndex, container);
if (result is DataTemplateSelector || result is FlowTemplateSelector)
throw new NotSupportedException("FlowTemplateSelector.OnSelectTemplate must not return another DataTemplateSelector");
return result;
}
示例13: OnItemsSourceChanged
private static void OnItemsSourceChanged(BindableObject bindable, IEnumerable oldvalue, IEnumerable newvalue)
{
var radios = bindable as BindableRadioButtonGroup;
if (radios == null)
{
return;
}
radios.RadioButtons.Clear();
radios.Children.Clear();
if (newvalue == null)
{
return;
}
var index = 0;
foreach (var item in newvalue)
{
var radioButton = new CustomRadioButton { Text = item.ToString(), Id = index };
radioButton.CheckedChanged += radios.OnCheckedChanged;
radios.RadioButtons.Add(radioButton);
radios.Children.Add(radioButton);
index++;
}
}
示例14: GetNativeView
public static Android.Views.View GetNativeView(BindableObject bindableObject)
{
var renderer = bindableObject.GetRenderer ();
var viewGroup = renderer.ViewGroup;
var rootView = viewGroup.RootView;
return rootView;
}
示例15: OnIsSelectedChanged
private static void OnIsSelectedChanged (BindableObject bindable, object oldvalue, object newvalue)
{
var tabButton = bindable as TabButton;
tabButton.BackgroundColor = tabButton.IsSelected ? AppConstants.HeaderBackground : Color.Transparent;
tabButton.TextColor = tabButton.IsSelected ? AppConstants.HeaderTextColour : AppConstants.TextColour;
}