What stereotype would be most suitable for an AutoCompleteBox?

What stereotype would be most suitable for an AutoCompleteBox?

Old forum URL: forums.lhotka.net/forums/t/8144.aspx


Jav posted on Monday, December 14, 2009

DynamicList would allow ability to add items not currently there (nice). But it would open the list to careless editing of existing items (not nice). I have a plethora of AutoCompleteBoxes. Items may be in hundreds.

Any ideas?
Javed

xAvailx replied on Monday, December 14, 2009

I've used NVL and ReadOnlyList to display the items. I would pass a filter and fetch the items from db.

Jav replied on Monday, December 14, 2009

Thanks.
ReadOnlyList may be a good choice with a single field in each item.

Jav replied on Friday, December 18, 2009

I am now using a ReadOnlyList. Here is what I have.

Class FamilyMemberList is a list of FamilyMember
Class FamilyMember has only one field named Member (a String)

Csla:CslaDataProvider x:Key="ListData"
ObjectType="ListsLibrary.FamilyMemberList, ListLibrary"
FactoryMethod="GetFamilyMemberList"
DataChangedHandler="{StaticResource DataErrorDialog}"
ManageObjectLifetime="True"
IsInitialLoadEnabled="True"

StackPanel x:Name="FamilyStackPanel"
DataContext="{Binding Source={StaticResource ListData},Path=Data}"

input:AutoCompleteBox x:Name="txtFamilyMember"
Width="145"
Text=""
Margin="0"
d:LayoutOverrides="Height"
ItemsSource="{Binding Path=Member}"

Nothing shows up in the AutoCompleteBox when I type f or m (Father, Mother) etc.

Probably my Binding is not correct. I have checked the data returned from the database and it is sound and the FamilyMemberList is populated correctly.

Javed

AutoCompleteBox ItemsSource="{Binding Path=Member}" was clearly wrong since I need to bind to the list, which I have now done in code behind. In Debug Watch window the ItemSource now has a list with the correct number of FamilyMember objects. AutoCompleteBox still auto completes nothing. How does the control know to bind to the Member Property of the object?

Jav replied on Friday, December 18, 2009

I got it. One has to override the ToString method in the member BusinessObject to return the property that should be displayed in the AutoCompleteBox.

Javed

Copyright (c) Marimer LLC