Exemplo n.º 1
0
 static void OnItemsSourceChanged(Control sender, AttachedPropertyChangedEventArgs<IEnumerable> e)
 {
     IItemsSourceFeature feature = sender.GetItemsSourceFeature();
     if(feature != null) {
         IEnumerable dataSource = (e.NewValue is INotifyCollectionChanged && e.NewValue is IList) ? BindingListAdapter.CreateFromList((IList)e.NewValue) : e.NewValue;//TODO
         feature.SetDataSource(sender, dataSource.With(x => new BindingSource() { DataSource = dataSource }));
     }
 }
Exemplo n.º 2
0
 static IEnumerable<AttachedPropertyBase> GetAttachedProperties(Control control)
 {
     yield return DataContextProvider.DataContextProperty;
     yield return CommandProvider.CommandProperty;
     yield return CommandProvider.CommandParameterProperty;
     if(control.GetItemsSourceFeature() != null) {
         yield return ItemsSourceProvider.ItemsSourceProperty;
         yield return ItemsSourceProvider.SelectedItemProperty;
     }
 }
Exemplo n.º 3
0
 internal static bool CanSerializeProperty(Control control, PropertyDescriptor property)
 {
     IItemsSourceFeature feature = control.GetItemsSourceFeature();
     if(feature != null) {
         if(control.GetItemsSource() == null)
             return true;
         return !feature.GetItemsSourceAffectedProperties().Any(x => (x == property.Name));
     }
     return true;
 }
Exemplo n.º 4
0
        static void OnSelectedItemChanged(Control sender, AttachedPropertyChangedEventArgs<object> e)
        {
            IItemsSourceFeature feature = sender.GetItemsSourceFeature();
            if(feature != null) {
                Action<Control> selectionChangedHandler = sender.GetValue(HandlerProperty);
                if(selectionChangedHandler == null) {
                    selectionChangedHandler = OnSelectionChanged;
                    sender.SetValue(HandlerProperty, selectionChangedHandler);
                    feature.AddSelectionChangedCallback(sender, selectionChangedHandler);
                }

                feature.SetSelectedItem(sender, e.NewValue);
                sender.SetSelectedItem(feature.GetSelectedItem(sender));
                //TODO test recursion or add assert
            }
        }
Exemplo n.º 5
0
 static void OnSelectionChanged(Control sender)
 {
     IItemsSourceFeature feature = sender.GetItemsSourceFeature();
     sender.SetSelectedItem(feature.GetSelectedItem(sender));
     //TODO test recursion or add assert
 }