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
No Data
Reply
  • 69686
    posted

    Hello Erwin,

    ItemSelected - if you want to bind it to whatever the XamDataGrid is bound to, you have to use something like this:

    Binding Path=DataPresenter.DataSource, RelativeSource={RelativeSouce TemplatedParent}.

    This should bind to the DataPresenter property of the CellValuePresenter, which represents the XamDataGrid.

    Items - I am not sure to what you want to bind this one. Can you please give us more specific details so that I can give you a proper xaml binding expression?

Children