My application is using Self-Tracking Entities & I get my data from a WCF Service. In my WCF service query I am using the .Include(“”) to load entity relationships with my query.
public List<IndividualDisability> GetIndividualDisabilities()
{
using (var context = new ADATrackingEntities())
{
return context.IndividualDisabilities.OfType<IndividualDisability>().Include("ADACode").ToList();
}
}
I’m then adding the results to an ICollectionView. I have a ListView that is bound to the ICollectionView, some of the columns in my ListView are bound to values from my entities relationship. I have a master-details setup with the current item of the listview bound to the entity object i’m editing.
<ListView Margin="0,0,10,0" MaxHeight="400" MaxWidth="300" HorizontalAlignment="Left" AlternationCount="2" ItemsSource="{Binding Path=IndividualDisabilitiesSource}" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=CurrentIndividualDisability, Mode=TwoWay}" SelectionMode="Single" ItemContainerStyle="{DynamicResource ListViewItemContainerStyle}">
<ListView.View>
<GridView>
<GridViewColumn Header="Case #" Width="Auto"
DisplayMemberBinding="{Binding Individual.CaseNumberShort}" />
<GridViewColumn Header="LName" Width="Auto"
DisplayMemberBinding="{Binding Individual.LastName}" />
<GridViewColumn Header="FName" Width="Auto"
DisplayMemberBinding="{Binding Individual.FirstName}" />
<GridViewColumn Header="ADA Code" Width="Auto"
DisplayMemberBinding="{Binding ADACode.ADACodeDesc}" />
</GridView>
</ListView.View>
</ListView>
The problem is that on my edit section i’m using a combobox to change a value from the selected record and its changing the related value in my ListView to a blank value in the cell. The only way I can get it to show up again is by going back to the database and loading the data again. Is there something im missing with my combobox or listview binding??
<ComboBox Height="25" Width="200" ItemsSource="{Binding ADACodesSource}"
DisplayMemberPath="ADACodeDesc" SelectedValuePath="ADACodeID"
SelectedValue="{Binding Path=CurrentIndividualDisability.ADACodeID, Mode=TwoWay,
NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
I havent been able to get it working still with the combobox, so I settled for creating a custom control. Its an AutoComplete/ComboBox that seems to have the correct type of binding. Everything works great with this control detailed in this blog post:
http://weblogs.asp.net/dwahlin/archive/2009/07/06/creating-an-combobox-style-autocompletebox-control-in-silverlight.aspx