示例#1
0
        private static SelectionHelperBehavior _getBehavior(FasterMultiSelectListBox obj)
        {
            var res = (SelectionHelperBehavior)obj.GetValue(_behaviorProperty);

            if (res == null)
            {
                res = new SelectionHelperBehavior(obj);
                _setBehavior(obj, res);

                var b1 = new Binding()
                {
                    Path   = new PropertyPath(ItemsControl.ItemsSourceProperty),
                    Mode   = BindingMode.OneWay,
                    Source = obj
                };

                obj.SetBinding(_itemsSourceProperty, b1);

                var b2 = new Binding()
                {
                    Path   = new PropertyPath(Selector.SelectedValuePathProperty),
                    Mode   = BindingMode.OneWay,
                    Source = obj
                };

                obj.SetBinding(_selectedValuePathProperty, b2);

                res.SetOnCleanup(() =>
                {
                    obj.ClearValue(_itemsSourceProperty);
                    obj.ClearValue(_selectedValuePathProperty);
                    obj.ClearValue(_behaviorProperty);
                });
            }
            return(res);
        }
示例#2
0
 private static void _setBehavior(FasterMultiSelectListBox obj, SelectionHelperBehavior value)
 {
     obj.SetValue(_behaviorProperty, value);
 }