Home Forums WPF controls Xceed DataGrid for WPF Static Bound XML in Resource

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

    <b>I would like to bind data as follows. If you paste this code into a .XAML file in Visual Studio, you’ll see the grid render but the data is not bound to the grid. Can you suggest what is wrong? Thanks very much.</b>

    <Page x:Class=”GridPage3″
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    Title=”Page3″
    >
    <!– GOAL: Use Xceed datatgrid bound to embedded static xml data –>
    <Page.Resources>
    <!– <XmlDataProvider x:Key=”EntGridRowDataDS” XPath=”ApplicationTree/Application” /> –>
    <XmlDataProvider x:Key=”EntGridRowDataDS” XPath=”EntGridRowData/Row”>
    <x:XData>
    <EntGridRowData xmlns=””>
    <Row>
    <account_contact.last_name>Ashton</account_contact.last_name>
    <account_contact.first_name>Nathalie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bengston</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    </EntGridRowData>
    </x:XData>
    </XmlDataProvider>

    </Page.Resources>

    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height=”100″/>
    <RowDefinition Height=”40″/>
    </Grid.RowDefinitions>
    <xcdg:DataGridControl Name=”Query” ReadOnly=”True” ItemsSource=”{Binding Mode=OneWay, Source={StaticResource EntGridRowDataDS}, XPath=EntGridRowDataDS/Row}”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”account_contact.last_name” Title=”Last Name” Width=”115″ DisplayMemberBinding=”{Binding XPath=account_contact.last_name}” />
    <xcdg:Column FieldName=”account_contact.first_name” Title=”First Name” Width=”107″ DisplayMemberBinding=”{Binding XPath=account_contact.first_name}” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
    </Grid>
    </Page>

    Imported from legacy forums. Posted by Marty (had 5057 views)

    User (Old forums)
    Member
    Post count: 23064

    <b>
    OK, it is fixed.
    But sorting and grouping are broken.
    I would like to ask a favor of anyone reading this.
    Can you please run this XAML in a sample project and tell me if you see that sorting and grouping are broken? I am pretty sure I’m using the latest version 1.0.7113.3050 unless my install is somehow broken and I have some old dlls laying around and therefore I am only seeing the old bug (now fixed) where sort was broken when binding to XML.
    Thanks to anyone who can help me with this sanity check.
    </b>

    <Page x:Class=”GridPage3″
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    Title=”Page3″
    >
    <!– GOAL: Use Xceed datatgrid bound to embedded static xml data –>
    <Page.Resources>
    <!– <XmlDataProvider x:Key=”EntGridRowDataDS” XPath=”ApplicationTree/Application” /> –>

    <XmlDataProvider x:Key=”DataSource1″>
    <x:XData>
    <Rows xmlns=””>
    <Row>
    <account_contact.last_name>Ashton</account_contact.last_name>
    <account_contact.first_name>Nathalie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bengston</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bush</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Boolean</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bengston</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Smith</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Frank</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Frank</account_contact.last_name>
    <account_contact.first_name>Barney</account_contact.first_name>
    </Row>
    </Rows>
    </x:XData>
    </XmlDataProvider>

    <XmlDataProvider x:Key=”DataSource2″ XPath=”Rows”>
    <x:XData>
    <Rows xmlns=””>
    <Row>
    <account_contact.last_name>Ashton</account_contact.last_name>
    <account_contact.first_name>Nathalie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bengston</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bush</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Boolean</account_contact.last_name>
    <account_contact.first_name>Sophie</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Bengston</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Smith</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Frank</account_contact.last_name>
    <account_contact.first_name>Ann</account_contact.first_name>
    </Row>
    <Row>
    <account_contact.last_name>Frank</account_contact.last_name>
    <account_contact.first_name>Barney</account_contact.first_name>
    </Row>
    </Rows>
    </x:XData>
    </XmlDataProvider>

    </Page.Resources>

    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height=”0.5*”/>
    <RowDefinition Height=”0.5*”/>
    </Grid.RowDefinitions>

    <xcdg:DataGridControl Grid.Row=”0″ x:Name=”Query1″ ReadOnly=”True” ItemsSource=”{Binding Mode=OneWay, Source={StaticResource DataSource1}, XPath=Rows/Row}” Margin=”5″>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”account_contact.last_name” Title=”Last Name” Width=”115″ DisplayMemberBinding=”{Binding XPath=account_contact.last_name}” />
    <xcdg:Column FieldName=”account_contact.first_name” Title=”First Name” Width=”107″ DisplayMemberBinding=”{Binding XPath=account_contact.first_name}” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    <xcdg:DataGridControl Grid.Row=”1″ x:Name=”Query2″ ReadOnly=”True” ItemsSource=”{Binding Mode=OneWay, Source={StaticResource DataSource2}, XPath=Row}” Margin=”5″>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”account_contact.last_name” Title=”Last Name” Width=”115″ DisplayMemberBinding=”{Binding XPath=account_contact.last_name}” />
    <xcdg:Column FieldName=”account_contact.first_name” Title=”First Name” Width=”107″ DisplayMemberBinding=”{Binding XPath=account_contact.first_name}” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>

    </Grid>
    </Page>

    Imported from legacy forums. Posted by Marty (had 407 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Marty,

    After checking your test program, I have been able to determine that this relates to an already known bug.

    The good news is that the bug in question has now been fixed.

    The fix has already been implemented and the main download package will be updated soon.

    Meanwhile you can download it using this link:

    http://download3.xceedsoft.com/Packages/3.0.7170.16360/XceedComponentsWebInstall.exe

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

    User (Old forums)
    Member
    Post count: 23064

    I seem to still be having this issue. My data is renedered properly, but sorting and grouping do not work.

    Here is the binding method

    Binding myBinding = new Binding();
    myBinding.Source = doc;
    myBinding.Mode = BindingMode.OneWay;
    myBinding.XPath = “/Patients/Patient”;
    grid.SetBinding(DataGridControl.ItemsSourceProperty, myBinding);

    The version of my Xceed.Wpf.Controls and Xceed.Wpf.DataGrid dlls is 1.2.7376.15420.

    Any thoughts?

    Imported from legacy forums. Posted by Matt (had 252 views)

    Xceed Support
    Member
    Post count: 5658

    By “does not work”, do you mean:

    – I cannot sort/group at all
    – Sorting and Grouping gives unexpected results

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

    User (Old forums)
    Member
    Post count: 23064

    My bad. I should be more specific. When I click on the column header, the order stays the same, but it may reverse the list, but not sort based on the column. You can tell it is trying to sort, but it seems like the comparator is not returning valid responses.

    Grouping seems to provide the same non-behavior. You can pull the column up to be grouped, but all the rows go into the same group.

    Imported from legacy forums. Posted by Matt (had 201 views)

    User (Old forums)
    Member
    Post count: 23064

    The other thing that just came to mind is that I am binding the columns to attributes and not to elements. Does that make a difference?

    Imported from legacy forums. Posted by Matt (had 239 views)

    User (Old forums)
    Member
    Post count: 23064

    I figured out the issue. I need to make sure that the FieldName property matches the attribute or element name. If you are using attributes, the FieldName needs to use the same syntax (FieldName = “@FirstName”, DisplayMemberBinding=”{Binding XPath=./@FirstName}”)

    Imported from legacy forums. Posted by Matt (had 6135 views)

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