Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Silverlight
Hai all,
 
In my Xaml page contains 1 combobox control (loading Districts from districtTable) ,textbox control to insert Taluk and Add button controls ,
For Add_Click event am inserting the District Id and Taluk names into database and displaying in a datagrid.Its working fine
 
Am facing problem during editing a datagrid, am getting District Id and district name on editing datagrid but not able to show in combobox (both DisplayMemberPath and SelectedValue)
 
Can any one help me in this please
 
Regards,
Sharath
Posted 2-Aug-12 20:26pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I hope you are using twoway binding everywhere ?
 
<combobox height="40" horizontalalignment="Stretch" verticalalignment="Center">
  Name="vormComboBox" Grid.Column="1" Margin="2"
  ItemsSource="{Binding ElementName=materiaalComboBox,Path=SelectedItem.Vormen}" 
  SelectedValuePath="Model.VormId" 
  ItemTemplate="{StaticResource FotoMateriaalVormTemplate}"   
  SelectedValue="{Binding Model.FotoVormId,Mode=TwoWay}"   
  SelectionChanged="vormComboBox_SelectionChanged">
  <combobox.itemspanel>
    <itemspaneltemplate>
      <virtualizingstackpanel />
    </itemspaneltemplate>
  </combobox.itemspanel>
</combobox>
  Permalink  
Comments
sharathrr at 3-Aug-12 3:07am
   
Hello,
 
In my Xaml page contains 1 combobox control (loading MainPurpose from MainPurposeTable) ,textbox control to insert Amount and Add button controls ,
For Add_Click event am inserting the MainPurpose Id and Amount into database and displaying in a datagrid.Its working fine

Am facing problem during editing a datagrid, am getting MainPurposeId and MainPurposeDesc on editing datagrid but not able to show in combobox (both DisplayMemberPath and SelectedValue)
 

 

 
private void GrdGCA_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(Row_MouseLeftButtonUp);
}

void Row_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
MnSubPurpose Puropse = GrdGCA.SelectedItem as MnSubPurpose;
LoadGCAMainPurpose();
cmbMnPurpose.SelectedValue = Puropse.MLnMnPurposeTId;
cmbMnPurpose.DisplayMemberPath = Puropse.MLnMnPurposeDesc;
cmbSubPurpose.SelectedValue = Puropse.MLnSubPurposeTId;
}
 


Can any one help me in this please

Regards,
Sharath
Philip Stuyck at 3-Aug-12 3:36am
   
The whole point of WPF is to use binding and to put the GUI as much as possible in the xaml. I suggest you read a bit more about xaml and binding. The easiest way to learn is to jump in the MVVM design pattern.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

May be you can add a EditItemTemplate inside your DataGrid.
 
Inside the specified column add a ComboBox field and bind its DataBinding property to your seleted value. Set the ItemSource, SelectedValuePath, SelectedDisplayMemberPath as you require it.
 
Hope it helps.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 359
1 Richard MacCutchan 320
2 OriginalGriff 240
3 Jared Sanow 145
4 Snehasish_Nandy 115
0 Sergey Alexandrovich Kryukov 5,969
1 OriginalGriff 5,005
2 CPallini 2,473
3 Richard MacCutchan 1,547
4 Abhinav S 1,507


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100