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
410
Column binding for multiple fields
posted

Hello, I believe this has been addressed already just from reading several of the posts but I just wanted to confirm after providing some code I used when using the standard WPF grid controls.  I am trying to concatenate more than one field and bind that to a column.

For example if i have three fields:  Source Return, Source Client ID and finally Return Name and I would like "Source Return" to be the combination of two fields, say "sourceClientID" and "sourceReturnVersion" how can I accomplish this in the xaml?

As I mentioned above, I previously could accomplish this in the old grid by implementing the following:

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

<GridViewColumn Header="Origin Name">

       <GridViewColumn.CellTemplate>

              <DataTemplate>

                     <StackPanel Orientation="Horizontal">

                            <TextBlock Text="{Binding SourceClientID}"/>

                            <TextBlock Text=":"/>

                           <TextBlock Text="{Binding SourceReturnVersion}"/>

                     </StackPanel>

              </DataTemplate>

       </GridViewColumn.CellTemplate>

</GridViewColumn>

 

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Is there anyway to do something similar to this in the xaml for xamDatagrid?  In a previous post it was said that this could not be accomplished in the xaml but could be accomplished by utlilizing RecordUpdated and InitializeRecord events.

 

I sincerely apologize if i'm doubling up on a post, but it is imperitive that I'm clear on this.  Thank you all so much!

 

 

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    You can use the DataItem and create a style like this:

     

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

                <Setter Property="Template">

                    <Setter.Value>

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

                            <StackPanel Orientation="Horizontal">

                                <TextBlock Text="{Binding Path=DataItem.FirstName}"/>

                               <TextBlock Text="+"/>

                                <TextBlock Text="{Binding Path=DataItem.LastName}"/>

                            </StackPanel>

                        </ControlTemplate>

                    </Setter.Value>

                </Setter>

            </Style>

    Alex.

     

Children
No Data