Ben*_*Ben 13 c# silverlight wpf silverlight-4.0
我正在尝试从ListBox中选择它时更改ListBoxItem上的Control模板.为此,我将从ListBox本身获取选定的ListBoxItem,并在其上设置控件模板.我该怎么做呢?我试过,SelectedItem并返回ListBoxItem中的绑定对象.
Tho*_*que 24
您可以使用以下命令从绑定项中检索项容器ItemContainerGenerator:
object selectedItem = listBox.SelectedItem;
ListBoxItem selectedListBoxItem = listBox.ItemContainerGenerator.ContainerFromItem(selectedItem) as ListBoxItem;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10641 次 |
| 最近记录: |