locked
DataGrid - ListBox - Selected Item RRS feed

  • Question

  • Good Day/Evening,

    I'm currenly trying to get this working with no luck, maybe I'm look in the wrong direction.

    What I'm Looking for:

    A listbox with 2 columns (stackpanels and textblocks etc) that will show a datagrids selected items details where the datagrid's columns IsVisble Property is equal to False

    E.G

    • Person Object
      • Name
      • Surname
      • Age
      • Height

    Data Grid binding to ObservableCollection(Of Person) with only 2 columns set as Visible (Name and Surname)

    -----------------------

    Name | Surname

    -----------------------

    John    | Smith          <------ Selected Item

    Danny | Cotze

    -----------------------

    When the user has selected a row in the datagrid, the listbox populates with the selected rows invisible colums. E.G

    ListBox (Data from Datagird Selected Item)

    ----------------------------------

    Age        |  31

    Height    |  1.8m

    ----------------------------------

    Any assistance would be greater appreciated, I would like to bind this using Two-Way Binding as I have a column chooser which will allow a user to set which columns are visible or not visible on the datagrid.

    Tuesday, September 21, 2010 1:56 AM

Answers

  • I dont undertand the reason behind using  listbox to show the details of the selected item in the datagrid. (I dont say it is not possible, but its not straight forward)

    Let me tell you a simple solution; Use DataForm - All you have to do is set the itemssource of the datagrid to the dataform as well;

     

    Done; (If you want further tunings, you can edit dataform datatemplate, its pretty straightforward) 

    Tuesday, September 21, 2010 2:32 AM

All replies

  • I dont undertand the reason behind using  listbox to show the details of the selected item in the datagrid. (I dont say it is not possible, but its not straight forward)

    Let me tell you a simple solution; Use DataForm - All you have to do is set the itemssource of the datagrid to the dataform as well;

     

    Done; (If you want further tunings, you can edit dataform datatemplate, its pretty straightforward) 

    Tuesday, September 21, 2010 2:32 AM
  • Thank you for your reply, I was thinking of using a dataform but the problem is that I do not know how to only show the InVisible Datagrid Columns when binding the Dataform to the Collection. I dont always want to edit the the dataform depening on the object, I would like the dataform to dynamicly know what fields to show based on a specfic datagrid.

    Any ideas on how i can do this?


    Tuesday, September 21, 2010 3:44 AM
  • You can show fields that are not shown in datagrid in the dataform;

    Use DataTempate

    e.g.

    <dataFormToolkit:DataForm.ReadOnlyTemplate>
                                <DataTemplate>
                                    <StackPanel>

    What will be the criteria for visibility of fields?

    Why cant you use converters to set the visibility;

    Tuesday, September 21, 2010 4:34 AM
  • Hi,

    I'll be using the column IsVisible property of the DataGrid to determine if the Dataform should show the field or not. I haven't really used converters, I'll do some research on the converters, thank you so far for the input you have given, you are helping me out alot!

    Tuesday, September 21, 2010 5:06 AM