Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8880091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:05:55+00:00 2026-06-14T20:05:55+00:00

List box is not binded just a Combobox replacement (values are exposed) Xaml <ListBox

  • 0

List box is not binded just a Combobox replacement (values are exposed)

Xaml

  <ListBox SelectionChanged="LBX_AddTaskOptions_SelectionChanged"  HorizontalAlignment="Left" Margin="19,29,0,0" Name="LBX_AddTaskOptions" VerticalAlignment="Top" Width="125" FontWeight="Bold" Background="Beige">
                        <ListBoxItem Background="Beige" FontWeight="Bold" v>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="internet"></TextBlock>
                                <Image Source="Images\IE_BlackRed.png" Height="30"></Image>
                            </StackPanel>
                        </ListBoxItem>
                        <ListBoxItem Background="Beige" FontWeight="Bold">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="localFolder"></TextBlock>
                                <Image Source="Images\Folder_Black.png" Height="30"></Image>
                            </StackPanel>
                        </ListBoxItem>
                    </ListBox>

CodeBehind

    private void LBX_AddTaskOptions_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var SelItm = LBX_AddTaskOptions.SelectedItem.ToString();

        MessageBox.Show(Sel);

    }

i have searched for that question, though answers are only for complex issues
as i am fresh .net Developer, i know all methods to extract DDL text/value
i even made extentions , though couldn’t figure how to do this simple value extraction

shouldn’t it be simple ?

messageBox shows the name of control (:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:05:57+00:00Added an answer on June 14, 2026 at 8:05 pm

    This isn’t quite the right approach for XAML. You don’t want to list out the markup for each item — instead, use an ItemTemplate to define how it should look, and use bindings to render the actual item:

    <ListBox SelectionChanged="LBX_AddTaskOptions_SelectionChanged" Name="LBX_AddTaskOptions">
        <ListBox.ItemTemplate>
            <ListBoxItem Background="Beige" FontWeight="Bold" v>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding}" />
                    <Image Source="Images\IE_BlackRed.png" Height="30" />
                </StackPanel>
            </ListBoxItem>
        </ListBox.ItemTemplate>
    </ListBox>
    

    Bind the ListBox ItemsSource to the model data itself (ie, the array of strings in this case). Now, eventually you’ll probably want to use a view model, but you can also add the items from code behind on load:

    string[] ListBoxItems = new string[] { "internet", "local folder" };
    LBX_AddTaskOptions.ItemsSource = ListBoxItems;
    

    This should result in SelectedValue giving you the correct value.


    Footnote — you could get the selected value using the markup you’ve written out in the question — but it would be ugly and would defeat the whole purpose of XAML. You’d need to cast SelectedItem to a ListBoxItem, then get its child and cast that to a StackPanel, get its children, etc, you get the idea. And then, of course, if the markup changes at all, the code you just wrote is no longer valid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am binding values to list box but string not showing in proper format.
i want to validate for listBox whether list box is empty of or not
I have a list box like this, <asp:ListBox ID=ListBox1 runat=server Height=175px Width=213px> <asp:ListItem Value=all>All</asp:ListItem>
I have editable dropdown list box on jquery grid, if I am not selecting
I have a list box in WPF as under <ListBox Name=lstName DisplayMemberPath =ListName ToolTip={Binding
The Drop-down list box does not display chinese characters in IE 7. Where as
I am trying to obtain all the values stored in a list box/drop down
I have a list box in my aspx page: <asp:ListBox ID=lstTreatmentProvider runat=server SelectionMode=Multiple Width=175px
I have a list box: <asp:ListBox ID="lstAppointment" runat="server"></asp:ListBox> I want to make it multicolumn.
Hi I have made checked List Box in WPF but the binding is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.