maui-linux/Xamarin.Forms.Core/Picker.cs

266 строки
8.1 KiB
C#
Исходник Обычный вид История

2016-03-22 23:02:25 +03:00
using System;
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
using System.Collections;
2016-03-22 23:02:25 +03:00
using System.Collections.Generic;
using System.Collections.ObjectModel;
2016-03-22 23:02:25 +03:00
using System.Collections.Specialized;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms.Internals;
2016-03-22 23:02:25 +03:00
using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_PickerRenderer))]
public class Picker : View, IFontElement, ITextElement, IElementConfiguration<Picker>
2016-03-22 23:02:25 +03:00
{
public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty;
2016-03-22 23:02:25 +03:00
public static readonly BindableProperty TitleProperty =
BindableProperty.Create(nameof(Title), typeof(string), typeof(Picker), default(string));
public static readonly BindableProperty SelectedIndexProperty =
BindableProperty.Create(nameof(SelectedIndex), typeof(int), typeof(Picker), -1, BindingMode.TwoWay,
propertyChanged: OnSelectedIndexChanged, coerceValue: CoerceSelectedIndex);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
public static readonly BindableProperty ItemsSourceProperty =
BindableProperty.Create(nameof(ItemsSource), typeof(IList), typeof(Picker), default(IList),
propertyChanged: OnItemsSourceChanged);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
public static readonly BindableProperty SelectedItemProperty =
BindableProperty.Create(nameof(SelectedItem), typeof(object), typeof(Picker), null, BindingMode.TwoWay,
propertyChanged: OnSelectedItemChanged);
2016-03-22 23:02:25 +03:00
public static readonly BindableProperty FontFamilyProperty = FontElement.FontFamilyProperty;
public static readonly BindableProperty FontSizeProperty = FontElement.FontSizeProperty;
public static readonly BindableProperty FontAttributesProperty = FontElement.FontAttributesProperty;
Platform Specifics (#301) * Playing around with how the platform specifics interfaces etc. might work * Sample implementation of iOS navigation translucency * Very slightly reduced code * Better vendor stuff * Drop single-implemenation interfaces * Generics on NavigationPage * On-demand vendor stuff * Remove functionally duplicate classes and make ControlGallery work again * Namespace all the things. XAML test. * Can use Effect to attach platform specific * Attach Effect on PropertyChanging for XAML support! * Rename IConfigPlatform interfaces for readability * Some renaming to match the documents * Split class files * Clear out test-only code * Re-namespace * Added On method to rendered Elements * Allow for removal of platform suffix, convenience methods on specific platforms * Creating a gallery page for specifics * Add rudimentary Platform Specifics gallery; make CollapseStyle work on UWP; Add CollapsedPaneWidth specific property * Toolbar now working with both collapse styles * MDP now displaying Content title; toolbar routing around title * Add a gallery for the iOS NavigationPage stuff * Add Navigation Page as detail page to verify it works with new Toolbar options * Make titlebar/toolbar background colors consistent * ToolbarPlacement now working on NavigationPage * Toolbar Placement working for tabbed and nav pages * Fix bug where phone doesn't get default toolbar placement on start * [Core] Add PS WindowSoftInputModeAdjust [Core] Make Application extendable * Toolbar placement now working on Nav, Tabbed, and Master pages on desktop/phone Remove unnecessary style indirection Fix build errors * [A] Add PlatformConfigurationExtensions * SetSoftInputMode test page * [A] SetSoftInputMode Known issue: Status bar color does not work in AdjustResize mode * [Core] Add PS Blur * [iOS] Configure renderer for blur * Add test page * Move to blur VisualElement for broader support * Move test pages to gallery * Update docs * Use lazy initializer for PlatformConfigurationRegistry
2016-08-30 20:46:14 +03:00
readonly Lazy<PlatformConfigurationRegistry<Picker>> _platformConfigurationRegistry;
2016-03-22 23:02:25 +03:00
public Picker()
{
((INotifyCollectionChanged)Items).CollectionChanged += OnItemsCollectionChanged;
Platform Specifics (#301) * Playing around with how the platform specifics interfaces etc. might work * Sample implementation of iOS navigation translucency * Very slightly reduced code * Better vendor stuff * Drop single-implemenation interfaces * Generics on NavigationPage * On-demand vendor stuff * Remove functionally duplicate classes and make ControlGallery work again * Namespace all the things. XAML test. * Can use Effect to attach platform specific * Attach Effect on PropertyChanging for XAML support! * Rename IConfigPlatform interfaces for readability * Some renaming to match the documents * Split class files * Clear out test-only code * Re-namespace * Added On method to rendered Elements * Allow for removal of platform suffix, convenience methods on specific platforms * Creating a gallery page for specifics * Add rudimentary Platform Specifics gallery; make CollapseStyle work on UWP; Add CollapsedPaneWidth specific property * Toolbar now working with both collapse styles * MDP now displaying Content title; toolbar routing around title * Add a gallery for the iOS NavigationPage stuff * Add Navigation Page as detail page to verify it works with new Toolbar options * Make titlebar/toolbar background colors consistent * ToolbarPlacement now working on NavigationPage * Toolbar Placement working for tabbed and nav pages * Fix bug where phone doesn't get default toolbar placement on start * [Core] Add PS WindowSoftInputModeAdjust [Core] Make Application extendable * Toolbar placement now working on Nav, Tabbed, and Master pages on desktop/phone Remove unnecessary style indirection Fix build errors * [A] Add PlatformConfigurationExtensions * SetSoftInputMode test page * [A] SetSoftInputMode Known issue: Status bar color does not work in AdjustResize mode * [Core] Add PS Blur * [iOS] Configure renderer for blur * Add test page * Move to blur VisualElement for broader support * Move test pages to gallery * Update docs * Use lazy initializer for PlatformConfigurationRegistry
2016-08-30 20:46:14 +03:00
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Picker>>(() => new PlatformConfigurationRegistry<Picker>(this));
2016-03-22 23:02:25 +03:00
}
public FontAttributes FontAttributes
{
get { return (FontAttributes)GetValue(FontAttributesProperty); }
set { SetValue(FontAttributesProperty, value); }
}
public string FontFamily
{
get { return (string)GetValue(FontFamilyProperty); }
set { SetValue(FontFamilyProperty, value); }
}
[TypeConverter(typeof(FontSizeConverter))]
public double FontSize
{
get { return (double)GetValue(FontSizeProperty); }
set { SetValue(FontSizeProperty, value); }
}
void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
void IFontElement.OnFontSizeChanged(double oldValue, double newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
void IFontElement.OnFontChanged(Font oldValue, Font newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
double IFontElement.FontSizeDefaultValueCreator() =>
Device.GetNamedSize(NamedSize.Default, (Picker)this);
void IFontElement.OnFontAttributesChanged(FontAttributes oldValue, FontAttributes newValue) =>
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
2016-03-22 23:02:25 +03:00
public IList<string> Items { get; } = new LockableObservableListWrapper();
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
public IList ItemsSource
{
get { return (IList)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
2016-03-22 23:02:25 +03:00
public int SelectedIndex
{
get { return (int)GetValue(SelectedIndexProperty); }
set { SetValue(SelectedIndexProperty, value); }
}
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
public object SelectedItem
{
get { return GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public Color TextColor {
get { return (Color)GetValue(TextElement.TextColorProperty); }
set { SetValue(TextElement.TextColorProperty, value); }
}
public string Title {
2016-03-22 23:02:25 +03:00
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
BindingBase _itemDisplayBinding;
public BindingBase ItemDisplayBinding {
get { return _itemDisplayBinding; }
set {
if (_itemDisplayBinding == value)
return;
2016-03-22 23:02:25 +03:00
OnPropertyChanging();
var oldValue = value;
_itemDisplayBinding = value;
OnItemDisplayBindingChanged(oldValue, _itemDisplayBinding);
OnPropertyChanged();
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
}
public event EventHandler SelectedIndexChanged;
static readonly BindableProperty s_displayProperty =
BindableProperty.Create("Display", typeof(string), typeof(Picker), default(string));
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
string GetDisplayMember(object item)
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
{
if (ItemDisplayBinding == null)
return item.ToString();
ItemDisplayBinding.Apply(item, this, s_displayProperty);
ItemDisplayBinding.Unapply();
return (string)GetValue(s_displayProperty);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
2016-03-22 23:02:25 +03:00
static object CoerceSelectedIndex(BindableObject bindable, object value)
{
var picker = (Picker)bindable;
return picker.Items == null ? -1 : ((int)value).Clamp(-1, picker.Items.Count - 1);
}
void OnItemDisplayBindingChanged(BindingBase oldValue, BindingBase newValue)
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
{
ResetItems();
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
{
SelectedIndex = SelectedIndex.Clamp(-1, Items.Count - 1);
UpdateSelectedItem();
}
static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
{
((Picker)bindable).OnItemsSourceChanged((IList)oldValue, (IList)newValue);
}
void OnItemsSourceChanged(IList oldValue, IList newValue)
{
var oldObservable = oldValue as INotifyCollectionChanged;
if (oldObservable != null)
oldObservable.CollectionChanged -= CollectionChanged;
var newObservable = newValue as INotifyCollectionChanged;
if (newObservable != null) {
newObservable.CollectionChanged += CollectionChanged;
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
if (newValue != null) {
((LockableObservableListWrapper)Items).IsLocked = true;
ResetItems();
} else {
((LockableObservableListWrapper)Items).InternalClear();
((LockableObservableListWrapper)Items).IsLocked = false;
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
}
void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
{
switch (e.Action) {
case NotifyCollectionChangedAction.Add:
AddItems(e);
break;
case NotifyCollectionChangedAction.Remove:
RemoveItems(e);
break;
default: //Move, Replace, Reset
ResetItems();
break;
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
}
void AddItems(NotifyCollectionChangedEventArgs e)
{
int index = e.NewStartingIndex < 0 ? Items.Count : e.NewStartingIndex;
foreach (object newItem in e.NewItems)
((LockableObservableListWrapper)Items).InternalInsert(index++, GetDisplayMember(newItem));
}
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
void RemoveItems(NotifyCollectionChangedEventArgs e)
2016-03-22 23:02:25 +03:00
{
int index = e.OldStartingIndex < Items.Count ? e.OldStartingIndex : Items.Count;
foreach (object _ in e.OldItems)
((LockableObservableListWrapper)Items).InternalRemoveAt(index--);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
void ResetItems()
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
{
if (ItemsSource == null)
return;
((LockableObservableListWrapper)Items).InternalClear();
foreach (object item in ItemsSource)
((LockableObservableListWrapper)Items).InternalAdd(GetDisplayMember(item));
UpdateSelectedItem();
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
static void OnSelectedIndexChanged(object bindable, object oldValue, object newValue)
{
var picker = (Picker)bindable;
picker.UpdateSelectedItem();
picker.SelectedIndexChanged?.Invoke(bindable, EventArgs.Empty);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
static void OnSelectedItemChanged(BindableObject bindable, object oldValue, object newValue)
{
var picker = (Picker)bindable;
picker.UpdateSelectedIndex(newValue);
}
void UpdateSelectedIndex(object selectedItem)
{
if (ItemsSource != null) {
SelectedIndex = ItemsSource.IndexOf(selectedItem);
return;
}
SelectedIndex = Items.IndexOf(selectedItem);
Squashed commit of the following: commit 8d784ec7459335ca33003844a793c3dd266c5861 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:30:25 2016 +0200 Added DisplayConverter property of type IValueConverter to perform conversion from object to string commit afb606f05c16b14e24785fad017540dd83dbf373 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Tue Aug 23 00:07:55 2016 +0200 Use IsValueType commit 4742c22ed33309f40a55c536b161292eb5db40f8 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:58:40 2016 +0200 Fixed bug with nested property expression commit 70a121e6172a61dbcf8835137bf58bd972cf2065 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Fri Aug 19 18:43:14 2016 +0200 Added more tests commit 49c7876bda4185c699f5fd9b3a66763efca9623c Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 18 13:28:36 2016 +0200 Siimplified setting SelectedItem. Added property to provide full control over how to display the objects by DisplayFunc. Added tests commit 5c1d5e149dc21c58cebf7cdbc6677d1ccec04ed4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:15:36 2016 +0200 Trying to fix formatting with tabs instead of spaces commit d64663ce3ef6b223a04d477274e93ec87bd38ff4 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 17:10:39 2016 +0200 Formatting. Handle Reset,Move,Replace collection changed action equal by re binding Items collection commit 8d4641810cb3b11fb6b47f8215bb5950a9641ba2 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:33:03 2016 +0200 Removed inline documentation. Fixed formatting commit 28010a1b31da02879fd2d549d5b02458766544d5 Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 16:29:37 2016 +0200 Removed SelectedValue since SelectedIndex and SelectedItem make it redundant commit ac9d65816fe6db7b467c304e6dc3168a84d3166b Author: Joakim Carselind <joakim.carselind@cub.se> Date: Thu Aug 11 14:51:20 2016 +0200 Initial attempt on bindable picker
2016-11-09 11:23:52 +03:00
}
void UpdateSelectedItem()
{
if (SelectedIndex == -1) {
SelectedItem = null;
return;
}
if (ItemsSource != null) {
SelectedItem = ItemsSource [SelectedIndex];
return;
}
SelectedItem = Items [SelectedIndex];
2016-03-22 23:02:25 +03:00
}
Platform Specifics (#301) * Playing around with how the platform specifics interfaces etc. might work * Sample implementation of iOS navigation translucency * Very slightly reduced code * Better vendor stuff * Drop single-implemenation interfaces * Generics on NavigationPage * On-demand vendor stuff * Remove functionally duplicate classes and make ControlGallery work again * Namespace all the things. XAML test. * Can use Effect to attach platform specific * Attach Effect on PropertyChanging for XAML support! * Rename IConfigPlatform interfaces for readability * Some renaming to match the documents * Split class files * Clear out test-only code * Re-namespace * Added On method to rendered Elements * Allow for removal of platform suffix, convenience methods on specific platforms * Creating a gallery page for specifics * Add rudimentary Platform Specifics gallery; make CollapseStyle work on UWP; Add CollapsedPaneWidth specific property * Toolbar now working with both collapse styles * MDP now displaying Content title; toolbar routing around title * Add a gallery for the iOS NavigationPage stuff * Add Navigation Page as detail page to verify it works with new Toolbar options * Make titlebar/toolbar background colors consistent * ToolbarPlacement now working on NavigationPage * Toolbar Placement working for tabbed and nav pages * Fix bug where phone doesn't get default toolbar placement on start * [Core] Add PS WindowSoftInputModeAdjust [Core] Make Application extendable * Toolbar placement now working on Nav, Tabbed, and Master pages on desktop/phone Remove unnecessary style indirection Fix build errors * [A] Add PlatformConfigurationExtensions * SetSoftInputMode test page * [A] SetSoftInputMode Known issue: Status bar color does not work in AdjustResize mode * [Core] Add PS Blur * [iOS] Configure renderer for blur * Add test page * Move to blur VisualElement for broader support * Move test pages to gallery * Update docs * Use lazy initializer for PlatformConfigurationRegistry
2016-08-30 20:46:14 +03:00
public IPlatformElementConfiguration<T, Picker> On<T>() where T : IConfigPlatform
{
return _platformConfigurationRegistry.Value.On<T>();
}
void ITextElement.OnTextColorPropertyChanged(Color oldValue, Color newValue)
{
}
2016-03-22 23:02:25 +03:00
}
}