I was checking this window. It has a listbox, and when you click an item, it shows three buttons.
I want to implement something similar in my program. How can I do that?
You can bind to the IsSelected
of the item, either by directly binding the Visibility
using a BooleanToVisibilityConverter
or by employing a DataTrigger
.
Direct Binding
<ListBox.Resources> <BooleanToVisibilityConverter x:Key="b2v"/> </ListBox.Resources>
<ListBox.ItemTemplate> <DataTemplate> <!-- ... --> <Button Visibility="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource b2v}}".../> </DataTemplate> </ListBox.ItemTemplate>
Style & DataTrigger
throw new NotImplementedException();
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.