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
  1. Home
  2. General Programming
  3. WPF
  4. How to Set ItemSource of Autocomplete Textbox when placed inside Datagrid and that datagrid having multiple rows???

How to Set ItemSource of Autocomplete Textbox when placed inside Datagrid and that datagrid having multiple rows???

Scheduled Pinned Locked Moved WPF
helptutorialquestion
7 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.
  • S Offline
    S Offline
    Shwetank123
    wrote on last edited by
    #1

    Hi, I am new to SilverLight, I have created one test Application having Datagrid and Autocomplete Text box which is placed inside the datagrid,Now if the there is only one row i am able to set itemsource of the Autocomplete text box but for multiple rows how to find the control and set the itemsource? Please help... Thanks & Best Regards Shwetank

    N 1 Reply Last reply
    0
    • S Shwetank123

      Hi, I am new to SilverLight, I have created one test Application having Datagrid and Autocomplete Text box which is placed inside the datagrid,Now if the there is only one row i am able to set itemsource of the Autocomplete text box but for multiple rows how to find the control and set the itemsource? Please help... Thanks & Best Regards Shwetank

      N Offline
      N Offline
      Naz_Firdouse
      wrote on last edited by
      #2

      Please check this tutorial... http://www.c-sharpcorner.com/UploadFile/dpatra/auto-complete-in-datagrid-cell-editing-in-silverlight-3-application/[^] hope it helps...

      S 1 Reply Last reply
      0
      • N Naz_Firdouse

        Please check this tutorial... http://www.c-sharpcorner.com/UploadFile/dpatra/auto-complete-in-datagrid-cell-editing-in-silverlight-3-application/[^] hope it helps...

        S Offline
        S Offline
        Shwetank123
        wrote on last edited by
        #3

        Hi, Thanks for the reply, I have already visited the link mentioned, the thing is in that i am using WCF service to get the data from database and i have placed Autocomplete textbox Control inside the datagrid for one row i am able to find the control and add the itemsource but if there are multiple rows then how do i do that? Thanks & Best Regards Shwetank

        N 1 Reply Last reply
        0
        • S Shwetank123

          Hi, Thanks for the reply, I have already visited the link mentioned, the thing is in that i am using WCF service to get the data from database and i have placed Autocomplete textbox Control inside the datagrid for one row i am able to find the control and add the itemsource but if there are multiple rows then how do i do that? Thanks & Best Regards Shwetank

          N Offline
          N Offline
          Naz_Firdouse
          wrote on last edited by
          #4

          It can be done in two ways... if the data to be binded to AutoComplete textbox is large, bind that collection to Autocomplete box by setting the datacontext to parent element of datagrid or first control in the page(we usually use grid as the main content holder) where that datacontext holds the Autocomplete collection and bind it to AutoCompleteBox. Here in this sample, they are binding some static resource. you can replace it with your collection and it gets binded.(Same collection gets binded to all AutoCompleteBox).

          <input:AutoCompleteBox

                                          HorizontalAlignment="Left"
          
                                          Width="180"
          
                                          IsTabStop="True"
          
                                          Text="{Binding UserName, Mode=TwoWay}"
          
                                          ItemsSource="{StaticResource SampleHeroes}"
          
                                          />
          

          another solution is if you want different collection to be binded, you can add one more property to Users class (in this sample) which holds the collection and you can bind it directly inside AutoCompleteBox.... e.g new Users{ UserName="Hiro Nakamura", Age=24, Gender="M", Country="Japan", AutoCompleteList = new List{"Hi","Hello","Welcome","Bye" } } But it does not seems to be good... you can use the first approach.

          S 1 Reply Last reply
          0
          • N Naz_Firdouse

            It can be done in two ways... if the data to be binded to AutoComplete textbox is large, bind that collection to Autocomplete box by setting the datacontext to parent element of datagrid or first control in the page(we usually use grid as the main content holder) where that datacontext holds the Autocomplete collection and bind it to AutoCompleteBox. Here in this sample, they are binding some static resource. you can replace it with your collection and it gets binded.(Same collection gets binded to all AutoCompleteBox).

            <input:AutoCompleteBox

                                            HorizontalAlignment="Left"
            
                                            Width="180"
            
                                            IsTabStop="True"
            
                                            Text="{Binding UserName, Mode=TwoWay}"
            
                                            ItemsSource="{StaticResource SampleHeroes}"
            
                                            />
            

            another solution is if you want different collection to be binded, you can add one more property to Users class (in this sample) which holds the collection and you can bind it directly inside AutoCompleteBox.... e.g new Users{ UserName="Hiro Nakamura", Age=24, Gender="M", Country="Japan", AutoCompleteList = new List{"Hi","Hello","Welcome","Bye" } } But it does not seems to be good... you can use the first approach.

            S Offline
            S Offline
            Shwetank123
            wrote on last edited by
            #5

            Hi, I tried using '' Tag but not getting.... Please find below the code i have tried...

            N 1 Reply Last reply
            0
            • S Shwetank123

              Hi, I tried using '' Tag but not getting.... Please find below the code i have tried...

              N Offline
              N Offline
              Naz_Firdouse
              wrote on last edited by
              #6

              it depends on the references you are using... you arealready using AutoCompleteBox in your app.so use the same but instead relpce its itemsource with a property name

              S 1 Reply Last reply
              0
              • N Naz_Firdouse

                it depends on the references you are using... you arealready using AutoCompleteBox in your app.so use the same but instead relpce its itemsource with a property name

                S Offline
                S Offline
                Shwetank123
                wrote on last edited by
                #7

                Hi, Could you please share sample code that would really help me a lot. and one more doubt: to get the city list there is one function written in .svc class, it is returning Generic List so how to convert that to objectCollection... Thanks & Best Regards Shwetank

                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