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
25
Field name must be unique. How to deal with object composition?
posted
Hi,

 

The list binded here is à list of Contacts objects. A contact is composed of an object ContactName which is composed of 2 strings “First” and “Last”.

My problem is the field name must be unique. So, how can I do to display ContactName.Last and ContactName.First in two differents columns.

 

This doesn’t work too:  <igDP:Field Name="ContactName.First" Label="Last Name">


 

Here is my xaml code:

 

 

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

    <Setter Property="Template">

        <Setter.Value>

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

                <Grid>

                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.First}"/>                                                                       

                                </Grid >

            </ControlTemplate>

        </Setter.Value>

    </Setter>

</Style>

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

    <Setter Property="Template">

        <Setter.Value>

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

                <Grid  >

                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Last}"/>                                                                        

                                </Grid >

            </ControlTemplate>

        </Setter.Value>

    </Setter>

</Style>

 



 

<TabItem Name="TabItemAllXamDataGrid"  Header="_All (XamDataGrid)" >

    <igDP:XamDataGrid Name="xamDataGridAll" BindToSampleData="False"  DataSource="{Binding}" GotFocus="xamDataGridAll_GotFocus" >

 

        <igDP:XamDataGrid.FieldLayoutSettings>

            <igDP:FieldLayoutSettings AutoGenerateFields="False"  />

        </igDP:XamDataGrid.FieldLayoutSettings>

        <igDP:XamDataGrid.FieldLayouts>

            <igDP:FieldLayout>

 

                <igDP:Field Name="ContactName" Label="Last Name">

                    <igDP:Field.Settings>

                        <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StyleTemplatePersonNameLast}" />

                    </igDP:Field.Settings>

                </igDP:Field>

 

 

!!! This doen’t work because field name must be unique !!!

                <igDP:Field Name=" ContactName " Label="First Name">

                    <igDP:Field.Settings>

                        <igDP:FieldSettings CellValuePresenterStyle="{StaticResource StyleTemplatePersonNameFirst}" />

                    </igDP:Field.Settings>

                </igDP:Field>

 

 

                </igDP:FieldLayout.Fields>

            </igDP:FieldLayout>

        </igDP:XamDataGrid.FieldLayouts>

 

    </igDP:XamDataGrid>
Parents
  • 339
    posted

    Don't know of an easy solution sorry.

    Can you not split the ContactName into unique properties in your Contact Class or even extend (via inheritance) the Contact Class to expose FirstName and LastName fields?

     Jamie.

Reply Children
No Data