Example #1
0
        /// <summary>
        /// Overrides the SelectionAdapter template part get method to inject
        /// the OverriddenSelectionAdapter type for Selector objects.
        /// </summary>
        /// <returns>Returns a new ISelectionAdapter instance or null.</returns>
        protected override ISelectionAdapter GetSelectionAdapterPart()
        {
            GetSelectionAdapterActions.DoPreTest();
            Selector          selector = GetTemplateChild("Selector") as Selector;
            ISelectionAdapter result   = selector != null ? new OverriddenSelectionAdapter(selector) : base.GetSelectionAdapterPart();

            GetSelectionAdapterActions.DoTest();
            return(result);
        }
 protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
 {
     base.OnAttachedToVisualTree(e);
     TablesListBox    = this.FindControl <ListBox>("TablesListBox");
     SelectionAdapter = new SelectingItemsControlSelectionAdapter(TablesListBox);
     DispatcherTimer.RunOnce(() =>
     {
         var searchTextBox = this.FindControl <TextBox>("SearchTextBox");
         searchTextBox?.Focus();
         searchTextBox?.SelectAll();
     }, TimeSpan.FromMilliseconds(1));
 }
Example #3
0
        /// <summary>
        /// Attempts to return an ISelectionAdapter wrapper for a specified object.
        /// </summary>
        /// <param name="value">The object value.</param>
        /// <returns>Returns an IItemsSelector wrapping the value.</returns>
        /// <remarks>
        /// The specified object will be returned if it implements
        /// ISelectionAdapter. If the specified object can be placed in a known
        /// implementation of ISelectionAdapter, one containing the specified
        /// object will be returned. Otherwise null will be returned.
        ///
        /// Custom adapters can be added by deriving a new control from
        /// AutoCompleteBox and overriding the TryGetSelectionAdapter method.</remarks>
        protected virtual ISelectionAdapter TryGetSelectionAdapter(object value)
        {
            // Check if it is already an IItemsSelector
            ISelectionAdapter asAdapter = value as ISelectionAdapter;

            if (asAdapter != null)
            {
                return(asAdapter);
            }

            // Built in support for wrapping a Selector control
            Selector asSelector = value as Selector;

            if (asSelector != null)
            {
                return(new SelectorSelectionAdapter(asSelector));
            }

            // TODO: PLANNING: Consider an Attribute to expose extensibility

            return(null);
        }