How to get particular property from item selected in ListBox

Pelle

I have the following:

<ListBox SelectedItem="{Binding SelectedItem}"
ItemsSource="{Binding items}" DisplayMemberPath="s"/>

<TextBlock Text="{Binding SelectedItem.s}"/>

This is definition of SelectedItem

public MemEntity SelectedItem {get; set;}

MemEntity is a class containing

public String s {get; get;}.

Basically, I want s of the selected item to be shown in the TextBlock (same property as shown in ListBox). This doesn't work, so what am I doing wrong?

Sajeetharan

Try this,

<TextBlock ... Text="{Binding ElementName=items, Path=SelectedItem.s}" />

then add a name to your ListBox as,

  <ListBox x:Name="items" SelectedItem="{Binding SelectedItem}"
        ItemsSource="{Binding items}" DisplayMemberPath="s"/>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get selected item of a listbox within a listbox

From Dev

How to get an image to display in Picturbox from a Listbox selected item

From Dev

Get selected item from databound ListBox

From Dev

How to get listbox selected item value

From Dev

How to get the index of a selected item in listbox and add to listbox two with button?

From Dev

How to get the index of a selected item in listbox and add to listbox two with button?

From Dev

Displaying the value of a property from a class according to selected item in listbox

From Dev

How to access a property of a selected item in a ListBox and paste it in TextBox

From Dev

How to change Listbox item color from selected Item(object)?

From Dev

Get Selected Item from Windows Phone listbox in Hold event

From Dev

Getting selected item from a listbox

From Dev

How can I get a listbox's selected item binded element?

From Java

How to show the numeric position from a selected item in a listbox in a label

From Dev

How to remove selected item from ListBox in windwos phone 8.1 Silverlight

From Dev

How to show data from selected item in listbox wpf using mvvm?

From Dev

Get object information of selected listbox item

From Dev

get Values of one listbox item selected

From Dev

Get object information of selected listbox item

From Dev

Listbox binding get selected item value

From Dev

Remove 3 rows from selected item in ListBox

From Dev

Remove selected item from listbox but also database

From Dev

How to get the selected item from a DropDownList?

From Dev

ListPicker, how to get the text from the selected item?

From Dev

How to get selected item from RecyclerView list?

From Dev

How to Get Selected Item From LibGDX List?

From Dev

how to get selected item from a combo box

From Dev

how to get the item selected from QListView?

From Dev

How to Get Selected Item From LibGDX List?

From Dev

How to get ALL selected items from ListBox into an EditBox?

Related Related

  1. 1

    How to get selected item of a listbox within a listbox

  2. 2

    How to get an image to display in Picturbox from a Listbox selected item

  3. 3

    Get selected item from databound ListBox

  4. 4

    How to get listbox selected item value

  5. 5

    How to get the index of a selected item in listbox and add to listbox two with button?

  6. 6

    How to get the index of a selected item in listbox and add to listbox two with button?

  7. 7

    Displaying the value of a property from a class according to selected item in listbox

  8. 8

    How to access a property of a selected item in a ListBox and paste it in TextBox

  9. 9

    How to change Listbox item color from selected Item(object)?

  10. 10

    Get Selected Item from Windows Phone listbox in Hold event

  11. 11

    Getting selected item from a listbox

  12. 12

    How can I get a listbox's selected item binded element?

  13. 13

    How to show the numeric position from a selected item in a listbox in a label

  14. 14

    How to remove selected item from ListBox in windwos phone 8.1 Silverlight

  15. 15

    How to show data from selected item in listbox wpf using mvvm?

  16. 16

    Get object information of selected listbox item

  17. 17

    get Values of one listbox item selected

  18. 18

    Get object information of selected listbox item

  19. 19

    Listbox binding get selected item value

  20. 20

    Remove 3 rows from selected item in ListBox

  21. 21

    Remove selected item from listbox but also database

  22. 22

    How to get the selected item from a DropDownList?

  23. 23

    ListPicker, how to get the text from the selected item?

  24. 24

    How to get selected item from RecyclerView list?

  25. 25

    How to Get Selected Item From LibGDX List?

  26. 26

    how to get selected item from a combo box

  27. 27

    how to get the item selected from QListView?

  28. 28

    How to Get Selected Item From LibGDX List?

  29. 29

    How to get ALL selected items from ListBox into an EditBox?

HotTag

Archive