當前位置: 首頁>>代碼示例>>C#>>正文


C# BindableObject類代碼示例

本文整理匯總了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
             {
             }
         }
     }
 }
開發者ID:woellij,項目名稱:LokalReporterApp,代碼行數:33,代碼來源:ArticleCarouselView.xaml.cs

示例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;
        }
開發者ID:zhangcj,項目名稱:Xamarin.Forms.Lagou,代碼行數:26,代碼來源:PickerBinder.cs

示例3: OnSelectTemplate

        protected override DataTemplate OnSelectTemplate(object item, int columnIndex, BindableObject container)
        {
            if (columnIndex == 0)
                return _leftTemplate;

            return _rightTemplate;
        }
開發者ID:daniel-luberda,項目名稱:DLToolkit.Forms.Controls,代碼行數:7,代碼來源:TemplateSelectorPageSelector.cs

示例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++;
         }
     }
 }
開發者ID:kirtisagar,項目名稱:XamarinFormsRadioButtonXAML,代碼行數:25,代碼來源:BindableRadioGroup.cs

示例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());
 }
開發者ID:xamarindevelopervietnam,項目名稱:XSkypeControl,代碼行數:7,代碼來源:SkypeAnimControl.cs

示例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;
            }
        }
開發者ID:gruan01,項目名稱:Xamarin-Example,代碼行數:27,代碼來源:ViewLocatorPage.cs

示例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 });
        }
開發者ID:Costo,項目名稱:Xamarin.Forms,代碼行數:7,代碼來源:Bz29300.xaml.cs

示例8: MergedStyle

            public MergedStyle(Type targetType, BindableObject target)
            {
                Target = target;
                TargetType = targetType;
                RegisterImplicitStyles();
                Apply(Target);
            }
開發者ID:Costo,項目名稱:Xamarin.Forms,代碼行數:7,代碼來源:MergedStyle.cs

示例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());
                    }
                }
            }
        }
開發者ID:RoyStobbelaar,項目名稱:MedewerkerTemp,代碼行數:41,代碼來源:BindablePicker.cs

示例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;
        }
開發者ID:jimbobbennett,項目名稱:JimLib.Xamarin,代碼行數:28,代碼來源:ToolBar.cs

示例11: ApplyStyle

 private static void ApplyStyle(BindableObject bindable, Style newvalue)
 {
   foreach (var setter in newvalue.Setters )
   {
       bindable.SetValue(setter.Property, setter.Value);
   }
 }
開發者ID:patridge,項目名稱:Xamarin.Forms.Plugins,代碼行數:7,代碼來源:ExtendedTextCell.cs

示例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;
        }
開發者ID:daniel-luberda,項目名稱:DLToolkit.Forms.Controls,代碼行數:14,代碼來源:FlowTemplateSelector.cs

示例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++;
            }
        }
開發者ID:JustinJohnWilliams,項目名稱:CustomRadioButtons,代碼行數:30,代碼來源:BindableRadioButtonGroup.cs

示例14: GetNativeView

 public static Android.Views.View GetNativeView(BindableObject bindableObject)
 {
     var renderer = bindableObject.GetRenderer ();
     var viewGroup = renderer.ViewGroup;
     var rootView = viewGroup.RootView;
     return rootView;
 }
開發者ID:Pizzajongen,項目名稱:TwinTechsFormsLib,代碼行數:7,代碼來源:RendererHelper.cs

示例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;
        }
開發者ID:Vineland,項目名稱:DarkestNight.App,代碼行數:7,代碼來源:TabButton.cs


注:本文中的BindableObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。