开发者

Finding controls in listboxitem by sender

开发者 https://www.devze.com 2023-01-10 12:19 出处:网络
I currently have (in C# WPF) a listbox with each item containing controls, among them a button and a progressbar. Now what I want to do, is the following:

I currently have (in C# WPF) a listbox with each item containing controls, among them a button and a progressbar. Now what I want to do, is the following:

Button mybutton = (Button)sender;开发者_C百科

I want to retrieve the progressbar that is in the same listboxitem as my sender button. How do I acces that control? Do I use the visualtreehelper?

Thanks in advance,


err, did you manually retemplate the listboxitem?

if it is, i believe you're using a container(such as grid) to host the button and progressbar. If that so, i think you can cast the sender into the container and loop for the children till you find the progressbar. if it's static, you can also find it using the index of the children.

0

精彩评论

暂无评论...
验证码 换一张
取 消