Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. WPF cascaded combo

WPF cascaded combo

Scheduled Pinned Locked Moved WPF
wpfcsharpdatabasecsswcf
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bindum31
    wrote on last edited by
    #1

    Hi, I am using LINQ to SQL and MVVM pattern in my application where i am retrieving my data by the following query:

    internal ObservableCollection GetCategoryList()
    {
    DataLoadOptions dataLoadOptions = new DataLoadOptions();
    dataLoadOptions.LoadWith(t => t.INVSubCategories);
    this.Context.LoadOptions = dataLoadOptions;

     var categories = from category in this.Context.INVCategories
                      orderby category.CatgeoryId descending
                      select category;
     return new ObservableCollection(categories.ToList());
    

    }

    And my XAML code for parent(Category) combo is:

    <ComboBox Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="0" x:Name="categoryComboBox"
    ItemsSource="{Binding CategoryList}" IsEditable="True" DisplayMemberPath="CategoryName" SelectedValuePath="CatgeoryId" SelectedItem="{Binding CategoryList, Mode=TwoWay}" SelectedValue="{Binding Path=CurrentEntity.CategoryId, Mode=TwoWay}" >
    </ComboBox>

    for child(Subcategory) combo i am using:

    <ComboBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="1"
    ItemsSource="{Binding SelectedItem, ElementName=categoryComboBox, Mode=OneWay}"
    DisplayMemberPath="SubCategoryName" SelectedValuePath="SubCategoryId"
    SelectedItem="{Binding INVSubCategories, Mode=TwoWay}">
    </ComboBox>

    But my child combo items is not populated during form loading as well as parent combo's selection changed though my parent combo items are populated. i can't figure out why my child combo is not functioning based on parent combo's selected item ,please help me.

    V 1 Reply Last reply
    0
    • B bindum31

      Hi, I am using LINQ to SQL and MVVM pattern in my application where i am retrieving my data by the following query:

      internal ObservableCollection GetCategoryList()
      {
      DataLoadOptions dataLoadOptions = new DataLoadOptions();
      dataLoadOptions.LoadWith(t => t.INVSubCategories);
      this.Context.LoadOptions = dataLoadOptions;

       var categories = from category in this.Context.INVCategories
                        orderby category.CatgeoryId descending
                        select category;
       return new ObservableCollection(categories.ToList());
      

      }

      And my XAML code for parent(Category) combo is:

      <ComboBox Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="0" x:Name="categoryComboBox"
      ItemsSource="{Binding CategoryList}" IsEditable="True" DisplayMemberPath="CategoryName" SelectedValuePath="CatgeoryId" SelectedItem="{Binding CategoryList, Mode=TwoWay}" SelectedValue="{Binding Path=CurrentEntity.CategoryId, Mode=TwoWay}" >
      </ComboBox>

      for child(Subcategory) combo i am using:

      <ComboBox Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,2,10,2" TabIndex="1"
      ItemsSource="{Binding SelectedItem, ElementName=categoryComboBox, Mode=OneWay}"
      DisplayMemberPath="SubCategoryName" SelectedValuePath="SubCategoryId"
      SelectedItem="{Binding INVSubCategories, Mode=TwoWay}">
      </ComboBox>

      But my child combo items is not populated during form loading as well as parent combo's selection changed though my parent combo items are populated. i can't figure out why my child combo is not functioning based on parent combo's selected item ,please help me.

      V Offline
      V Offline
      Venkatesh Mookkan
      wrote on last edited by
      #2

      Check whether you implemented INotifyPropertyChanged interface for Category class object.

      Castle Rider

      What if I freeze??? Don't forget to breath...

      My: Website | Yahoo Group | Blog Spot

      /xml>

      B 1 Reply Last reply
      0
      • V Venkatesh Mookkan

        Check whether you implemented INotifyPropertyChanged interface for Category class object.

        Castle Rider

        What if I freeze??? Don't forget to breath...

        My: Website | Yahoo Group | Blog Spot

        /xml>

        B Offline
        B Offline
        bindum31
        wrote on last edited by
        #3

        Thanks Castle Rider for your reply. I have made a Generic "BasePresenter" class where i have implemented INotifyPropertyChanged interface in the following way:

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
        PropertyChangedEventHandler handler = this.PropertyChanged;
        if (handler != null)
        {
        handler(this, new PropertyChangedEventArgs(propertyName));
        }
        }

        And in my Presenter class I have used:

            public ObservableCollection<INVCategory> CategoryList
            {
                get
                {
                    return this.categoryList;
                }
        
                set
                {
                    this.categoryList = value;
                    **OnPropertyChanged**("CategoryList");
                    
                }
            }
        
        V 1 Reply Last reply
        0
        • B bindum31

          Thanks Castle Rider for your reply. I have made a Generic "BasePresenter" class where i have implemented INotifyPropertyChanged interface in the following way:

          public event PropertyChangedEventHandler PropertyChanged;

          protected void OnPropertyChanged(string propertyName)
          {
          PropertyChangedEventHandler handler = this.PropertyChanged;
          if (handler != null)
          {
          handler(this, new PropertyChangedEventArgs(propertyName));
          }
          }

          And in my Presenter class I have used:

              public ObservableCollection<INVCategory> CategoryList
              {
                  get
                  {
                      return this.categoryList;
                  }
          
                  set
                  {
                      this.categoryList = value;
                      **OnPropertyChanged**("CategoryList");
                      
                  }
              }
          
          V Offline
          V Offline
          Venkatesh Mookkan
          wrote on last edited by
          #4

          Try adding UpdateSourceTrigger=PropertyChanged along with the ItemsSource Binding xaml.

          Castle Rider

          What if I freeze??? Don't forget to breath...

          My: Website | Yahoo Group | Blog Spot

          /xml>

          B 1 Reply Last reply
          0
          • V Venkatesh Mookkan

            Try adding UpdateSourceTrigger=PropertyChanged along with the ItemsSource Binding xaml.

            Castle Rider

            What if I freeze??? Don't forget to breath...

            My: Website | Yahoo Group | Blog Spot

            /xml>

            B Offline
            B Offline
            bindum31
            wrote on last edited by
            #5

            I am not clear. Would you please send me a sample code.

            V 1 Reply Last reply
            0
            • B bindum31

              I am not clear. Would you please send me a sample code.

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              Try this binding in categoryCombo SelectedValue="{Binding Path=CurrentEntity.CategoryId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

              Castle Rider

              What if I freeze??? Don't forget to breath...

              My: Website | Yahoo Group | Blog Spot

              /xml>

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups