Home Forums WPF controls Xceed DataGrid for WPF Binding a DataGridCollectionViewSource to Window property

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

    I have a DataGridCollectionViewSource in Window.Respoures. I’d like to bind its source to a property of the current window. This doesn’t work:

    <Window …
    x:Name=”myFundWindow”>
    <Window.Resources>

    <xcdg:DataGridCollectionViewSource x:Key=”PacketsDGSource”
    Source=”{Binding ElementName=myFundWindow, Path=Packets}”>
    <xcdg:DataGridCollectionViewSource.SortDescriptions>
    <compModel:SortDescription PropertyName=”Requested”
    Direction=”Descending”/>
    </xcdg:DataGridCollectionViewSource.SortDescriptions>
    </xcdg:DataGridCollectionViewSource>

    I’m getting:
    System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Packets; DataItem=null; target element is ‘DataGridCollectionViewSource’ (HashCode=10648649); target property is ‘Source’ (type ‘Object’)

    Seems like is doesn’t know what myFundWindow is. How can I fix this?

    Brian

    Imported from legacy forums. Posted by Brian (had 665 views)

    Xceed Support
    Member
    Post count: 5658

    Try something like this:

    Source=”{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},
    Path=Packets}”>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 148 views)

    User (Old forums)
    Member
    Post count: 23064

    I have tried the suggestion above and I am still having problems binding from a DatagridCollectionViewSource.
    Here is a subset of the XAML:

    <Page.Resources>

    <xcdg:DataGridCollectionViewSource x:Key=”cvsRows” Source=”{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Page}},Path=Timesheet.Rows}”>
    </Page.Resources>

    I get the following error in the list:
    System.Windows.Data Error: 4 : Cannot find source for binding with reference ‘RelativeSource FindAncestor, AncestorType=’System.Windows.Controls.Page’, AncestorLevel=’1”. BindingExpression:Path=Timesheet.Rows; DataItem=null; target element is ‘DataGridCollectionViewSource’ (HashCode=39696553); target property is ‘Source’ (type ‘Object’)

    Imported from legacy forums. Posted by scottr (had 3572 views)

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