Home Forums WPF controls Xceed DataGrid for WPF Problem with datagrid.ItemsSource

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25590 |

    Hello I am using and testing Xceed DataGrid to WPF. I need some help.

    I have the following code in a page called Page1.xaml.cs :

    public partial class Page1 : Page

    {

    CtrlerCasoUso ctler;

    StateCasoUso estado;

    public Page1()

    {

    InitializeComponent();

    Xceed.Wpf.DataGrid.Licenser.LicenseKey = “XXX-XXX-XXX-XXXX”;

    ctler = new CtrlerCasoUso();

    estado = new StateCasoUso();

    ctler.StateCasoUso = estado;

    ctler.GetInitialData();

    GridPrueba.ItemsSource = estado.Customers;

    GridPrueba.ReadOnly = false;

    }

    }

    ….

    estado.Customer is a List<EntCustomer> object that contain objects EntCustomer:

    class EntCustomer

    {

    private string id;

    private string companyName;

    public string Id

    {

    get { return id; }

    set { id = value; }

    }

    public string CompanyName

    {

    get { return companyName; }

    set { companyName = value; }

    }

    }

    ….

    And the code of XAML file is :

    <Page x:Class=”WPFGrid.Page1″

    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;

    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;

    Title=”Page1″ Width=”1024″ Height=”640″

    xmlns:my=”clr-namespace:Xceed.Wpf.DataGrid;assembly=Xceed.Wpf.DataGrid”

    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;

    xmlns:s=”clr-namespace:System;assembly=mscorlib”>

    <Grid>

    <xcdg:DataGridControl Height=”185″ Margin=”137.5,130,177.5,0″ Name=”GridPrueba” AutoCreateColumns=”False”>

    <xcdg:DataGridControl.Columns>

    <xcdg:Column Title =”ID” FieldName=”Id” DisplayMemberBinding=”{Binding XPath=id}” />

    <xcdg:Column Title =”Compañia” FieldName=”CompanyName” DisplayMemberBinding=”{Binding XPath=CompanyName}”/>

    </xcdg:DataGridControl.Columns>

    </xcdg:DataGridControl>

    </Grid>

    </Page>

    And the runtime, only display:

    The headers: ID, Compañia

    The data are not displayed, only the count of rows.

    If estado.Customers object have five entities, only five rows are displayed with neither data.

    | ID | compañia |

    | | |

    | | |

    | | |

    | | |

    | | |

    I need to look the data. What is my mistake or error?

    somebody maybe help me.

    Imported from legacy forums. Posted by cams_aries2 (had 3460 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    In the DisplayMemberBinding, XPath must be used only when data source is XML. In your case, you should be using the Path instead.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 318 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi
    try this, u hav to add item source tag to the grid control
    <xcdg:DataGridControl
    Background=”BlanchedAlmond”
    Name=”P2PGrid”
    FontFamily=”Arial”
    FontSize=”12″
    ItemsSource=”{Binding Path=Table}”
    BorderThickness=”0″
    DockPanel.Dock=”Top” Height=”180″>

    regards,
    dontula

    Imported from legacy forums. Posted by dontula (had 341 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Marcus:

    I used DisplayMemberBinding=”{Binding Path=CompanyName}”. the result was the same,
    neither data.

    thank you for reply.

    Imported from legacy forums. Posted by cams_aries2 (had 440 views)

    User (Old forums)
    Member
    Post count: 23064

    hello Marcus

    your answer really works!, the problem was the security. I actived the reflectionPermission and data were showed.

    thank you.

    Imported from legacy forums. Posted by cams_aries2 (had 4642 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.