Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
Help with dynamic columns and dynamic databounding
posted

Hi

I have to add dynamic columns to my XamDataGrid, the thing is that for each dynamic columns I have a custom style template with a custom user control inside, this user control is almost the same as a combo box, it has items and it has a selected item.

My problem is that the grid have to bind to one source and my:ScoreControl  have to bind to another source dinamycally generated, and the SelectedItem property of my:ScoreControl have to bind with the same source of my grid has. 

This is easy in WinForm but I having problem in WPF, I wondering if anyone can help me.

 <Style x:Key="id6" TargetType="{x:Type igDP:CellValuePresenter}">

   <Setter Property="Template">

    <Setter.Value>

      <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">

 

          <my:ScoreControl Items="{Binding ???}"  

 

                                       ItemSelected="{Binding ???}"></my:ScoreControl>

        </StackPanel>

 

      </ControlTemplate>

 

    </Setter.Value>

  </Setter>

</Style>

 Maybe I'm not on the right way, and please tell me if I'm not clear.

Parents Reply
  • 210
    posted in reply to John Doe

    The thing that is generated dynamically here you are a draw that explain my escenario better.

    As you can see in the image, I have collections that are generated dynamically, the example you mentioned is using a xmldataprovider, In this case I think I have to follow the next steps:

    1.- Create resources dynamically. (Collection X, Y and Z)

    2.- Create my DataTable with Title, Velocity, Rated and Recommended columns

    3.- Fill my DataTable with the title and for the other columns fill with the ID of the already selected item.

    4.- Bind my custom user control of every column to the respective resource.

    My problem is Step 1 and Step 4. I dont know how to do it dynamically :(

Children