none
twoway databinding of a join query RRS feed

  • Question

  • Hi,

    is there a way to make twoway databinding for a join llinq query result ?

    let's say that i have Features table and Customer_selection table .


    what i want is to to show the list of all the Features in a listbox for example with a checkbox.

    so when the user click on the checkbox , a new Customer_selection entity is added with checked Feature,

    if the user uncheck the Feature the Customer_selection entity will be removed for the datacontext


    what's the best way to do that please ?


    thanks and good day

    Tuesday, December 9, 2014 10:40 AM

Answers

  • Well , i have found a solution that seems to work actually

    something like :

      var query = from u in FEATURES
                            join pp in features_selection on u equals pp.feature into gj
                            from subpet in gj.DefaultIfEmpty()
                            select new customType
                            {
                                feature = u,
                                feature_selection = subpet
                            };
                listbox.ItemsSource = query;

    the customtype déclaration is like this

       public class CustomType
        {
            public FEATURE feature { get; set; }
            public FEATURE_SELECTION feature_selection { get;set; }
        }



    in the listbox itemtemplate i have checkbox that handle the checked and unchecked events and do the logic manually .


    like i said it worked,  but i am wondering if there is a solution in pure xaml with databinding only except for the join query


    Wednesday, December 10, 2014 1:20 PM

All replies

  • I will assume that the "join" was on some child table to a parent. The children objects they would be in a collection object like a List<T>.  So yeah, you can create a new child object and do a Collection.Add() or Collection.RemoveAt()

    http://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx

    Wednesday, December 10, 2014 3:21 AM
  • Well , i have found a solution that seems to work actually

    something like :

      var query = from u in FEATURES
                            join pp in features_selection on u equals pp.feature into gj
                            from subpet in gj.DefaultIfEmpty()
                            select new customType
                            {
                                feature = u,
                                feature_selection = subpet
                            };
                listbox.ItemsSource = query;

    the customtype déclaration is like this

       public class CustomType
        {
            public FEATURE feature { get; set; }
            public FEATURE_SELECTION feature_selection { get;set; }
        }



    in the listbox itemtemplate i have checkbox that handle the checked and unchecked events and do the logic manually .


    like i said it worked,  but i am wondering if there is a solution in pure xaml with databinding only except for the join query


    Wednesday, December 10, 2014 1:20 PM
  • like i said it worked,  but i am wondering if there is a solution in pure xaml with databinding only except for the join query

    They use EF and XAML at the below forum.

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf

    Wednesday, December 10, 2014 4:10 PM