I have that listbox: my bind is ProdutoGrupoViewModel, and list named as ListBoxGrupos
<ListBox HorizontalAlignment="x:Name="ListBoxGrupos"
ItemsSource="{Binding ProdutoGrupoViewModel}"
SelectionChanged="ListBoxGrupos_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate x:Name="ListViewGrupos">
<StackPanel>
<TextBlock Text="{Binding Descricao}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
and when i get on my xaml.cs the property ListBoxGrupos.selectedItem, that returns for me an object
that object have some attributes
Obj.Descricao = "Pizzas"
Obj.GrupoCor = "FF8040"
Obj.GrupoID = 3
Obj.Image = "..."
Obj.Position = "0" ```
(i tried to upload the image of that obj, but need reputation, so i tried to explain)
i want to know how can i get the attribute GrupoID.
You need to cast the object to specified class
Grupo gru = (Grupo)ListBoxGrupos.SelectedItem;
gru.GrupoID = 3;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.