Пример #1
0
        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;
        }
 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
             {
             }
         }
     }
 }
 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++;
         }
     }
 }
Пример #4
0
        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;
            }
        }
//		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());
					}
				}
			}
		}
Пример #6
0
        private static void CommandParameterPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var gesture = ((ExtendedImage) bindable)._tapGestureRecognizer;

            if (gesture != null && gesture.Command != null)
                ((RelayCommand)gesture.Command).RaiseCanExecuteChanged();
        }
 private static void ApplyStyle(BindableObject bindable, Style newvalue)
 {
   foreach (var setter in newvalue.Setters )
   {
       bindable.SetValue(setter.Property, setter.Value);
   }
 }
        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++;
            }
        }
		protected override DataTemplate OnSelectTemplate(object item, int columnIndex, BindableObject container)
		{
			if (columnIndex == 0)
				return _leftTemplate;

			return _rightTemplate;
		}
Пример #10
0
        private static void OnItemsSourcePropertyChanged(BindableObject bindable, IEnumerable<ILabel> oldvalue,
            IEnumerable<ILabel> newvalue)
        {
            var control = bindable as Label;
            control.FormattedText = null;

            if (newvalue == null) return;

            var formattedString = new FormattedString();
            foreach (var label in newvalue)
            {
                var color = Color.FromHex(label.Color);

                formattedString.Spans.Add(new Span
                {
                    Text = $"\u00A0{label.Name}\u00A0",
                    ForegroundColor =
                        (Color)
                            Application.Current.Resources[
                                (color.Hue > 0 ? "PrimaryLightTextColor" : "PrimaryDarkTextColor")],
                    BackgroundColor = color
                });
                formattedString.Spans.Add(new Span
                {
                    Text = " "
                });
            }

            control.FormattedText = formattedString;
        }
Пример #11
0
		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 });
		}
        /// <summary>
        /// Creates an instance of the GridDefinitionBindingHack class.
        /// </summary>
        private GridDefinitionBindingHelper(GridSplitter s, BindableObject o, BindableProperty p, BindableProperty p2)
        {
            // preconditions

            Argument.IsNotNull("s", s);
            Argument.IsNotNull("o", o);
            Argument.IsNotNull("p", p);

            // implementation

            this.splitter = s;
            this.bindableObject = o;
            this.sizeProperty = p;
            this.visibleProperty = p2;

            // update the property if the column width/row height changes.
            s.MouseLeftButtonUp += delegate(object sender, MouseButtonEventArgs e)
            {
                this.AdjustPropertyValue();
            };

            // update the column width/row height if the property value changes.
            o.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == this.sizeProperty.Name ||
                    (this.visibleProperty != null && e.PropertyName == this.visibleProperty.Name))
                {
                    this.AdjustDefinationValue();
                }
            };
        }
        /// <summary>
        /// Called when [items source property changed].
        /// </summary>
        /// <param name="bindable">The bindable.</param>
        /// <param name="value">The value.</param>
        /// <param name="newValue">The new value.</param>
        private static void OnItemsSourcePropertyChanged(BindableObject bindable, IEnumerable value, IEnumerable newValue)
        {
            var picker = (BindablePicker)bindable;
            var notifyCollection = newValue as INotifyCollectionChanged;
            if (notifyCollection != null) {
                notifyCollection.CollectionChanged += (sender, args) => {
                    if (args.NewItems != null) {
                        foreach (var newItem in args.NewItems) {
                            picker.Items.Add ((newItem ?? "").ToString ());
                        }
                    }
                    if (args.OldItems != null) {
                        foreach (var oldItem in args.OldItems) {
                            picker.Items.Remove ((oldItem ?? "").ToString ());
                        }
                    }
                };
            }

            if (newValue == null)
                return;

            picker.Items.Clear ();

            foreach (var item in newValue)
                picker.Items.Add ((item ?? "").ToString ());
        }
Пример #14
0
			public MergedStyle(Type targetType, BindableObject target)
			{
				Target = target;
				TargetType = targetType;
				RegisterImplicitStyles();
				Apply(Target);
			}
 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());
 }
Пример #16
0
		static void OnHorizontalTextAlignmentPropertyChanged(BindableObject bindable, object oldValue, object newValue)
		{
			var label = (EntryCell)bindable;
#pragma warning disable 0618 // retain until XAlign removed
			label.OnPropertyChanged(nameof(XAlign));
#pragma warning restore
		}
Пример #17
0
        private static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
        {
            BoundPicker boundPicker = (BoundPicker)bindable;
            //boundPicker.BatchBegin ();
            try
            {
                boundPicker.Items.Clear();
                var enumerable = newValue as IEnumerable;
                if (enumerable != null && enumerable.GetEnumerator().MoveNext())
                {
                    foreach (var item in enumerable)
                    {
                        boundPicker.Items.Add(item.ToString());
                    }
                }
                else
                {
                    boundPicker.Items.Add(" ");
                }

                boundPicker.InternalUpdateSelectedIndex();
            }
            finally {
                //boundPicker.BatchCommit ();
            }
        }
 public static Android.Views.View GetNativeView(BindableObject bindableObject)
 {
     var renderer = bindableObject.GetRenderer ();
     var viewGroup = renderer.ViewGroup;
     var rootView = viewGroup.RootView;
     return rootView;
 }
Пример #19
0
		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;
		}
		/// <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;
		}
Пример #21
0
 static void loadItemsAndSetSelected(BindableObject bindable)
 {
     ExtendedPicker picker = (ExtendedPicker)bindable;
     if (picker.ItemsSource as IEnumerable != null)
     {
         int count = 0;
         foreach (object obj in (IEnumerable)picker.ItemsSource)
         {
             string value = string.Empty;
             if (picker.DisplayProperty != null)
             {
                 var prop = obj.GetType().GetRuntimeProperties().FirstOrDefault(p => string.Equals(p.Name, picker.DisplayProperty, StringComparison.OrdinalIgnoreCase));
                 if (prop != null)
                 {
                     value = prop.GetValue(obj).ToString();
                 }
             }
             else
             {
                 value = obj.ToString();
             }
             picker.Items.Add(value);
             if (picker.SelectedItem != null)
             {
                 if (picker.SelectedItem == obj)
                 {
                     picker.SelectedIndex = count;
                 }
             }
             count++;
         }
     }
 }
Пример #22
0
        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;
        }
Пример #23
0
 private static void OnSelectedItemChanged(BindableObject bindable, object oldvalue, object newvalue)
 {
     var picker = bindable as BindablePicker;
     if (newvalue != null)
     {
         picker.SelectedIndex = picker.Items.IndexOf(newvalue.ToString());
     }
 }
		static void OnContentChanged( BindableObject bindable, object oldvalue, object newvalue )
		{
			var view = bindable as ContentView;
			if ( view != null )
			{
				view.Content = newvalue as View;
			}
		}
Пример #25
0
 /// <summary>
 ///  Clears the cache when the set of templates change
 /// </summary>
 /// <param name="bo"></param>
 /// <param name="oldval"></param>
 /// <param name="newval"></param>
 public static void TemplatesChanged(BindableObject bo, DataTemplateCollection oldval, DataTemplateCollection newval)
 {
     var ts = bo as TemplateSelector;
     if (ts == null) return;
     if (oldval != null) oldval.CollectionChanged -= ts.TemplateSetChanged;
     newval.CollectionChanged += ts.TemplateSetChanged;
     ts.Cache = null;
 }
Пример #26
0
		internal override void SetUp(BindableObject bindable)
		{
			object newvalue = bindable.GetValue(Property);

			bool newState = (newvalue == Value) || (newvalue != null && newvalue.Equals(Value));
			bindable.SetValue(_stateProperty, newState);
			bindable.PropertyChanged += OnAttachedObjectPropertyChanged;
		}
			protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
			{
				if (item is double)
					return templateOne;
				if (item is byte)
					return new TestDTS ();
				return templateTwo;
			}
Пример #28
0
			public void Apply(BindableObject bindable)
			{
				ImplicitStyle?.Apply(bindable);
				if (ClassStyles != null)
					foreach (var classStyle in ClassStyles)
						((IStyle)classStyle)?.Apply(bindable);
				Style?.Apply(bindable);
			}
        private static void OnImageSourceChanged(BindableObject bindable, string oldvalue, string newvalue)
        {
            if (Device.OS == TargetPlatform.Android) return;
            var image = (XLargeImage)bindable;

            var baseImage = (Image)bindable;
            baseImage.Source = image.ImageSource;
        }
Пример #30
0
		void OnAggregatedStatePropertyChanged(BindableObject bindable, object oldValue, object newValue)
		{
			if ((bool)oldValue == (bool)newValue)
				return;

			if (ConditionChanged != null)
				ConditionChanged(bindable, (bool)oldValue, (bool)newValue);
		}
Пример #31
0
 public static void SetVerifyNumericValue(BindableObject view, bool value)
 {
     view.SetValue(VerifyNumericValueProperty, value);
 }
Пример #32
0
 private static void OnCollectionChangedListenerChanging(BindableObject bindable, object oldValue, object newValue)
 {
     (oldValue as CollectionChangedListener)?.Dispose();
 }
Пример #33
0
 internal static void SetRaiseCanExecuteChangedInternal(BindableObject view, Action value) => view.SetValue(RaiseCanExecuteChangedInternalProperty, value);
Пример #34
0
 /// <summary>
 /// Gets the Bindable Can Navigate property for an element
 /// </summary>
 /// <param name="view">The bindable element</param>
 public static bool GetCanNavigate(BindableObject view) => (bool)view.GetValue(CanNavigateProperty);
Пример #35
0
 public static DataTemplate GetItemTemplate(BindableObject bindable) => (DataTemplate)bindable.GetValue(ItemTemplateProperty);
Пример #36
0
 private static CollectionChangedListener GetCollectionChangedListener(BindableObject bindable) => (CollectionChangedListener)bindable.GetValue(CollectionChangedListenerProperty);
Пример #37
0
Файл: Page.cs Проект: hevey/maui
 public static bool GetUseSafeArea(BindableObject element)
 {
     return((bool)element.GetValue(UseSafeAreaProperty));
 }
Пример #38
0
Файл: Page.cs Проект: hevey/maui
 public static LargeTitleDisplayMode GetLargeTitleDisplay(BindableObject element)
 {
     return((LargeTitleDisplayMode)element.GetValue(LargeTitleDisplayProperty));
 }
Пример #39
0
 public static void SetCornerRadius(BindableObject view, int value) =>
 view.SetValue(CornerRadiusProperty, value);
Пример #40
0
 public static void IsIndicatorRunningChanged(BindableObject bindableObject, object oldValue, object newValue) => (bindableObject as LoadingButtonControl).IsIndicatorRunning = (bool)newValue;
Пример #41
0
 public static void ClickCommandChanged(BindableObject bindableObject, object oldValue, object newValue) => (bindableObject as LoadingButtonControl).ClickCommand = (Command)newValue;
Пример #42
0
 /// <summary>
 /// Sets the Bindable Can Navigate property for an element
 /// </summary>
 /// <param name="view">The bindable element</param>
 /// <param name="value">The Can Navigate value</param>
 public static void SetCanNavigate(BindableObject view, bool value) => view.SetValue(CanNavigateProperty, value);
Пример #43
0
 private static void SetCollectionChangedListener(BindableObject bindable, CollectionChangedListener value) => bindable.SetValue(CollectionChangedListenerProperty, value);
Пример #44
0
 /// <summary>
 /// Convenience helper, which enables you to bind any property
 /// of your View Model to an object you pass in.
 /// </summary>
 protected void BindToViewModel(BindableObject self, BindableProperty targetProperty,
                                Expression <Func <TViewModel, object> > sourceProperty, BindingMode mode = BindingMode.Default,
                                IValueConverter converter = null, string stringFormat = null)
 {
     self.SetBinding(targetProperty, sourceProperty, mode, converter, stringFormat);
 }
Пример #45
0
 public static void SetSeparatorTemplate(BindableObject bindable, DataTemplate value) => bindable.SetValue(SeparatorTemplateProperty, value);
Пример #46
0
 public static int GetCornerRadius(BindableObject view) =>
 (int)view.GetValue(CornerRadiusProperty);
Пример #47
0
 public static DataTemplate GetSeparatorTemplate(BindableObject bindable) => (DataTemplate)bindable.GetValue(SeparatorTemplateProperty);
Пример #48
0
 public static void SetItemsSource(BindableObject bindable, IEnumerable value) => bindable.SetValue(ItemsSourceProperty, value);
Пример #49
0
 public static void SetItemTemplate(BindableObject bindable, DataTemplate value) => bindable.SetValue(ItemTemplateProperty, value);
Пример #50
0
Файл: Page.cs Проект: hevey/maui
 public static void SetLargeTitleDisplay(BindableObject element, LargeTitleDisplayMode value)
 {
     element.SetValue(LargeTitleDisplayProperty, value);
 }
Пример #51
0
 internal static void SetRealCell(BindableObject cell, UITableViewCell renderer)
 {
     cell.SetValue(RealCellProperty, renderer);
 }
Пример #52
0
        private static void OnCanNavigatePropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var action = GetRaiseCanExecuteChangedInternal(bindable);

            action?.Invoke();
        }
Пример #53
0
 public static IEnumerable GetItemsSource(BindableObject bindable) => (IEnumerable)bindable.GetValue(ItemsSourceProperty);
Пример #54
0
 internal static UITableViewCell GetRealCell(BindableObject cell)
 {
     return((UITableViewCell)cell.GetValue(RealCellProperty));
 }
Пример #55
0
Файл: Page.cs Проект: hevey/maui
 public static void SetUseSafeArea(BindableObject element, bool value)
 {
     element.SetValue(UseSafeAreaProperty, value);
 }
Пример #56
0
 internal static Action GetRaiseCanExecuteChangedInternal(BindableObject view) => (Action)view.GetValue(RaiseCanExecuteChangedInternalProperty);
Пример #57
0
 public static void SetAppearing(BindableObject bindable, bool value)
 {
     bindable.SetValue(AppearingProperty, value);
 }
Пример #58
0
 public static bool GetVerifyNumericValue(BindableObject view)
 {
     return((bool)view.GetValue(VerifyNumericValueProperty));
 }
Пример #59
0
 public static bool GetAppearing(BindableObject bindable)
 {
     return((bool)bindable.GetValue(AppearingProperty));
 }
Пример #60
0
Файл: Page.cs Проект: hevey/maui
 public static UIStatusBarAnimation GetPreferredStatusBarUpdateAnimation(BindableObject element)
 {
     return((UIStatusBarAnimation)element.GetValue(PreferredStatusBarUpdateAnimationProperty));
 }