Home Forums WPF controls Xceed DataGrid for WPF Linq 2 WPF for noobs

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

    Totally new to XAML, Linq and WPF and feeling a bit lost.

    I have a Linq to SQL project called myData than contains myxTable.cs defining myxTableDataContext and myxTable. The name space is myx.Data.

    I’m creating a WPF user control, myxControl that contains a dataGridControl.

    In the XAML under <UserControl I reference my Linq project:

    xmlns:myx=”clr-namespace:myx.Data;assembly=myxData”

    then I create a <Grid.Resources> section and attempt to add the <xcdg:DataGridCollectionViewSource

    Key seems obvious it just a variable reference? so…

    source is where I hang:

    <xcdg:DataGridCollectionViewSource x:Key=”tableData” Source=”{Binding Source={x: WhatShouldSourceBe? }}”, Path=View? />

    I can’t seem to get the source and/or the View correct, and when I play with it VS2008 crashes. (the crash is mentioned in other posts, so I won’t bring it up here.)

    Imported from legacy forums. Posted by John (had 3291 views)

    User (Old forums)
    Member
    Post count: 23064

    Having it crash VS every time you edit the binding source is a pain. 🙁

    Here’s what I have now:

    c#:

    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Controls;
    using myxData;

    namespace myxControls
    {
    public partial class testXAML : UserControl
    {

    public myxDC;
    public IEnumerable<myxTable> testx;

    public testXAML()
    {
    myxTableDataContext dc = new myxTableDataContext();
    testx = from x in dc.myxTable select x;
    InitializeComponent();
    }
    }
    }

    XAML:

    <UserControl x:Class=”myxControls.testXAML”
    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;
    xmlns:local=”clr-namespace:myxControls”
    Height=”237″ Width=”523″ Margin=”0″>
    <Grid Height=”237″ Width=”523″>
    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”tableData” Source=”{Binding Source={x:Type local:testXAML},Path=testx}” />
    </Grid.Resources>
    <xcdg:DataGridControl
    Name=”dataGridControl1″
    ItemsSource=”{Binding Source={StaticResource tableData}}” />
    </Grid>
    </UserControl>

    It compiles and runs without error, But the grid is empty when it displays.

    What am I doing wrong?

    Imported from legacy forums. Posted by John (had 584 views)

    User (Old forums)
    Member
    Post count: 23064

    Never did get that technique to work. I ended up removing the grid resources and setting it by putting this after the InitializeComponent() in the code behind:

    dataGridControl1.ItemsSource = testx;

    Imported from legacy forums. Posted by John (had 426 views)

    User (Old forums)
    Member
    Post count: 23064

    Finally got it.

    used this post http://forums.xceed.com/Forums/ShowPost.aspx?PostID=11292 and set the DataContext in the code behind.

    Full source for my solution is here:

    http://www.universalthread.com/wconnect/wc.dll?2,15,1296587 (To see the Ling portion look at the previous post.)

    Hopefully this helps someone, it was a real pain to figure out.

    Imported from legacy forums. Posted by John (had 3230 views)

    User (Old forums)
    Member
    Post count: 23064

    I found that the UniversalThread site failed to show anything at all.

    The message and troubleshooting seemed to indicate that my machine is too secure!!!

    For me this link is, unfortunately, unreadable.

    Imported from legacy forums. Posted by MikeGale (had 2330 views)

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