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. WCF and WF
  4. Listbox

Listbox

Scheduled Pinned Locked Moved WCF and WF
wpf
8 Posts 3 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.
  • R Offline
    R Offline
    RongNK
    wrote on last edited by
    #1

    I want to host controls within a ListBoxItem (ListBox control).Code XAML:

    < ListBoxItem Background="LightBlue"
    Foreground="Blue" FontFamily="Verdana" FontSize="12" FontWeight="Bold">
    < CheckBox Name="IcedTeaCheckBox">
    < Image Source="temp.jpg" Height="30">
    < TextBlock Text="Iced Tea">< /TextBlock>

    But i want to solve that by Coded-Behind. :-O sorry for my english. Thank :-O

    C M 2 Replies Last reply
    0
    • R RongNK

      I want to host controls within a ListBoxItem (ListBox control).Code XAML:

      < ListBoxItem Background="LightBlue"
      Foreground="Blue" FontFamily="Verdana" FontSize="12" FontWeight="Bold">
      < CheckBox Name="IcedTeaCheckBox">
      < Image Source="temp.jpg" Height="30">
      < TextBlock Text="Iced Tea">< /TextBlock>

      But i want to solve that by Coded-Behind. :-O sorry for my english. Thank :-O

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You want to add the controls in your code behind instead, or you want to access them there ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      R 1 Reply Last reply
      0
      • C Christian Graus

        You want to add the controls in your code behind instead, or you want to access them there ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        R Offline
        R Offline
        RongNK
        wrote on last edited by
        #3

        Both :) Thank !

        C 1 Reply Last reply
        0
        • R RongNK

          Both :) Thank !

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          The listboxitem has AddChild and AddVisualChild methods. It also has a GetVisualChild method for getting back child elements. I'd say that's the way to go.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          R 1 Reply Last reply
          0
          • C Christian Graus

            The listboxitem has AddChild and AddVisualChild methods. It also has a GetVisualChild method for getting back child elements. I'd say that's the way to go.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            R Offline
            R Offline
            RongNK
            wrote on last edited by
            #5

            I don't understand. Can't you give more detail ? Thank !

            C 1 Reply Last reply
            0
            • R RongNK

              I don't understand. Can't you give more detail ? Thank !

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Not really, no. The methods are, IMO, self documenting. I've never done what you want to do, I just took the time to google it for you.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              R 1 Reply Last reply
              0
              • C Christian Graus

                Not really, no. The methods are, IMO, self documenting. I've never done what you want to do, I just took the time to google it for you.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                R Offline
                R Offline
                RongNK
                wrote on last edited by
                #7

                Thank !

                1 Reply Last reply
                0
                • R RongNK

                  I want to host controls within a ListBoxItem (ListBox control).Code XAML:

                  < ListBoxItem Background="LightBlue"
                  Foreground="Blue" FontFamily="Verdana" FontSize="12" FontWeight="Bold">
                  < CheckBox Name="IcedTeaCheckBox">
                  < Image Source="temp.jpg" Height="30">
                  < TextBlock Text="Iced Tea">< /TextBlock>

                  But i want to solve that by Coded-Behind. :-O sorry for my english. Thank :-O

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  What are you having trouble with? If you want to create controls from code, just create control objects and set properties on those objects. e.g.

                  //< ListBoxItem removed="LightBlue" 
                  //Foreground="Blue" FontFamily="Verdana" FontSize="12" FontWeight="Bold">
                  //    <  CheckBox Name="IcedTeaCheckBox">
                  //        "Horizontal">
                  //            < Image Source="temp.jpg" Height="30"></Image>
                  //            < TextBlock Text="Iced Tea">< /TextBlock>        
                  
                  ListBoxItem item = new ListBoxItem();
                  item.Foreground = new SolidColorBrush(Colors.Blue);
                  item.FontSize = 12;
                  item.FontWeight = FontWeights.Bold;
                  CheckBox cb = new CheckBox();
                  cb.Name = "IcedTeaCheckBox";
                  //etc....
                  item.Content = cb;
                  

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  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