Home Forums WPF controls Xceed DataGrid for WPF Binding isn’t working

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

    My XAML binding in this example isn’t working.

    XAML:

    <Window.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”searchDataView”
    Source=”{Binding Path=Packets, RelativeSource={RelativeSource AncestorType={x:Type Window}}}” />
    </Window.Resources>


    <xcdg:DataGridControl x:Name=”PacketGrid” CellEditorDisplayConditions=”MouseOverCell”
    EditTriggers=”BeginEditCommand,ActivationGesture”
    ItemScrollingBehavior=”Immediate” AutoCreateColumns=”True”
    ItemsSource=”{Binding Source={StaticResource searchDataView}, Path=View}”/>

    Code-behind:
    public List<FundPacket> Packets
    {
    set { _packets = value; OnPropertyChanged(“Packets”); }
    get { return _packets; }
    }
    private List<FundPacket> _packets = new List<FundPacket>();

    void Window1_Loaded(object sender, RoutedEventArgs e)
    {
    this.Packets.Add(new FundPacket());

    // This works, but the DataGrid doesn’t update as the data changes.
    //DataGridCollectionViewSource viewsource = (DataGridCollectionViewSource)this.FindResource(“searchDataView”);
    //viewsource.Source = this.Packets;

    }

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

    Xceed Support
    Member
    Post count: 5658

    What are the binding errors displayed in the output window?

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

    User (Old forums)
    Member
    Post count: 23064

    Jenny,

    No compiler or binding errors. I just never see the data in the UI. Seems like change notification in the DataGridCollectionViewSource doesn’t work when bound to a List<>. I’ve used it before with BindingList<> and it works fine, so maybe it’s something I’m doing.

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

    Xceed Support
    Member
    Post count: 5658

    List<> does not have a notification system so the grid will never be able to update when bound to that kind of source.

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

    User (Old forums)
    Member
    Post count: 23064

    I’m using a foreach loop to move the contents of my List<> into a BindingList<>. Now the binding works.

    Thanks!

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

    User (Old forums)
    Member
    Post count: 23064

    I’m having the same problem but with datasets (eg. no compile errors, no binding errors, and no data 🙁 , I’m using version 1.3

    Here is a part of my xaml

    <Window.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvsProducts” x:Name=”gridView” Source=”{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}”>
    <xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridGroupDescription PropertyName=”BrandID”/>
    </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridCollectionViewSource.StatFunctions>
    <xcdg:SumFunction ResultPropertyName=”SumOfQuantity” SourcePropertyName=”Quantity”/> <xcdg:SumFunction ResultPropertyName=”SumOfPurchased”
    SourcePropertyName=”Purchased”/>
    <xcdg:SumFunction ResultPropertyName=”SumOfUsed”
    SourcePropertyName=”Used”/>
    <xcdg:SumFunction ResultPropertyName=”SumOfUnitPrice”
    SourcePropertyName=”UnitPrice”/>
    </xcdg:DataGridCollectionViewSource.StatFunctions>
    </xcdg:DataGridCollectionViewSource>
    <Window.Resources>

    <Grid x:Name=”LayoutRoot” DataContext=”{Binding Source={x:Static Application.Current},Path=Products}”>
    <xcdg:DataGridControl x:Name=”grid” ItemScrollingBehavior=”Immediate” Margin=”3,3,3,3″ ItemsSource=”{Binding Source={StaticResource cvsProducts}}”
    NavigationBehavior=”RowOnly”>

    Products=DataSet

    Imported from legacy forums. Posted by averbeka (had 4818 views)

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