I have a simple user control that is essentially just an auto-computer with some user logic.
For a specific instance (collection of faces) I want it to look like this:
<sdk:AutoCompleteBox Name="myACB" ItemsSource="{Binding People}" FilterMode="StartsWith" MinimumPrefixLength="2" ValueMemberBinding={Binding LastName}> <sdk:AutoCompleteBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding LastName}" /> </DataTemplate> </sdk:AutoCompleteBox.ItemTemplate> </sdk:AutoCompleteBox>
However, I want the data source to be shared, and so the display values will be different (ValueMemberBinding and text TextBlock of the template). This is why I am creating a custom control, so I can point out the differences with the properties.
I have no problem setting the source using the user control property, but I am having difficulty with the display binding properties. Right now I have:
public static DependencyProperty DisplayMemberProperty = DependencyProperty.Register("DisplayMember", typeof(string), typeof(myAutoComplete), null); public string DisplayMember { get { return myACB.ValueMemberPath; } set { myACB.ValueMemberPath = value;
I want the DisplayMember property to be the property name displayed for any type of user collection (faces, cars, etc.). I got attached to autocomplete.
I do not think that I can modify the datatemplate programmatically. Is there a way to do this with binding (relative source)?
source share