CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Silverlight to WPF conversion Issue with AutoCompleteBox

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 5 Replies | 1 Follower

    Top 25 Contributor
    397 Posts
    Jav posted on Wed, Jun 10 2015 10:39 AM

    I am bringing my mature SL app to WPF. I am quite liberal with the use of AutoCompleteBoxes and often have more than one on a page.

    The data for the dropdown of each Auto...box comes from a database table.  Instead of running to the Database for each Auto..box's list, I bring up the list for the whole page, and then use a subset of that list when the user navigates to a given Auto...box.  All my lists are of the MobileList kind.  This has worked fine in SL. (The same is happening with BusinessListBase)


    In WPF the behavior is strange.  The lists do appear in the dropdown, but when I choose an item with mouse the selection immediately disappears and the box remains empty.  When I make the selection by using the up-down arrow keys on the keyboard, the selection behaves normally.


    Now here is the interesting part.  If, instead of displaying the subset (Path = FilteredList), I use the entire list (Path = Model), everything works fine.  The workaround I have used on one instance of AutoCompleteBox is to create another class specifically to hold the selected subset.  Using that I can set the Path = Model, and with that things appear to work.  With the number Auto..boxses, making the change to all is, well, daunting.
    So I thought I should ask if there is a simpler solution for this. 

    I'll appreciate any suggestions.

    Javed

    Answered (Verified) Verified Answer

    Top 25 Contributor
    397 Posts
    Answered (Verified) Jav replied on Fri, Jun 12 2015 9:12 AM
    Verified by Andy

    Found the culprit.  One of my methods in the chain was getting called mare than once, when it was meant to be called only once. On the last go around it was clearing my list.

    Javed

    All Replies

    Top 10 Contributor
    9,475 Posts

    How do you create the FilteredList collection?

    Rocky

    • Filed under:
    Top 25 Contributor
    397 Posts
    Jav replied on Wed, Jun 10 2015 11:39 AM

    The main list is created as:

    public partial class PxAttributeValueList : MobileList<PxAttributeValue>

    Within this class I have a method:

    public PxAttributeValueList GetFilteredList(string region, string part)
         {
                 PxAttributeValueList Lst = new PxAttributeValueList();
                 for (int j = 0; j < this.Count; j++)
                        {
                          // based on region and part
                          Lst.Add(this[j]);
                        } 
                return Lst;
         }

    The resulting "FilteredList" is used in Path = FilteredList

    Javed

    Top 10 Contributor
    9,475 Posts

    You are using a very basic list type - MobileList inherits from List<T>. No explicit data binding support, but then binding to a combobox doesn't require anything special.

    It is quite puzzling that the same list type works as .Model but not as .Model.FilteredList.

    I see no async behavior there, so that probably isn't an issue.

    Does your FilteredList property raise PropertyChanged after it has been set/changed?

    Rocky

    Top 25 Contributor
    397 Posts
    Jav replied on Wed, Jun 10 2015 12:29 PM

    FilteredList after being created as I displayed above simply goes back. In SL it works just fine.  In WPF, I changed the list to

    public partial class PxAttributeSelectionList : BusinessListBase<PxAttributeValueList, PxAttributeValue>

    But that made no difference to the behavior.  I then created another class and I use it as follows: 

        [Serializable]
        public class PxAttributeSelectionList : BusinessListBase<PxAttributeValueList, PxAttributeValue>
        {
            public static void NewPxAttributeSelectionList(EventHandler<DataPortalResult<PxAttributeSelectionList>> callback)
            {
                var dp = new DataPortal<PxAttributeSelectionList>();
                dp.FetchCompleted += callback;
                dp.BeginFetch();
            }

            public static PxAttributeSelectionList NewPxAttributeSelectionList()
            {
                return new PxAttributeSelectionList();
            }

        }

    Then instead of the "FilteredList" I do the following:

    public PxAttributeValueList GetFilteredList(string region, string part)
      {
                PxAttributeSelectionList Lst = new PxAttributeSelectionList ();
                for (int j = 0; j < this.Count; j++)
                    {
                    // based on region and part
                       Lst.Add(this[j]);
                    }
                 return Lst;
      }

    With that list, I can use Path = Model, and everything works just fine.

    Javed

    Top 25 Contributor
    397 Posts
    Answered (Verified) Jav replied on Fri, Jun 12 2015 9:12 AM
    Verified by Andy

    Found the culprit.  One of my methods in the chain was getting called mare than once, when it was meant to be called only once. On the last go around it was clearing my list.

    Javed

    Page 1 of 1 (6 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems