I'm trying to force the DataForm to display an initial value that's different from the first of the ItemsSource list with no success.
I'm working with the MVVM patern.
I simply bind the ItemsSource to a Customers list (All customers), then bind CurrentItem to the one customer I want to be displayed as an initial item on the DataForm:
<toolkit:DataForm Height="292"
HorizontalAlignment="Left"
ItemsSource="{Binding Path=Customers}"
CurrentItem="{Binding SelectedCustomer}"
Margin="88,122,0,0"
Name="customerDataForm"
VerticalAlignment="Top"
Width="342" />
And in the viewmodel I set:
void loadOpCustomers_Completed(object sender, EventArgs e) {
Customers = _Context.Customers;
SelectedCustomer = Customers.Where(c => c.CustomerID == initialCustomerID).FirstOrDefault();
}
When I debug it SelectedCustomer holds the exact customer I want, but the DataForm insists to show the first of the Customers list.
Any suggestion?
Add a binding mode in your XAML:
ItemsSource="{Binding Path=Customers}"
CurrentItem="{Binding SelectedCustomer,Mode=TwoWay}"
And make sure your ViewModel implements INotifyPropertyChanged.