c# - How can I access the ItemsPanel of a ListBox at runtime in silverlight? -


How do I use the items panel in a list box at runtime in Silverlight?

There are two ways to achieve this, the simplest is the Silverlight Toolkit:

  using System.Windows.Controls.Primitives; Private Zero LB_loaded () {var itemsPanel = LB.GetVisualChildren (.) OfType & lt; Panel & gt; (). FirstOrDefault (); }  

Or you can use VisualTreeHelper and type the following recursive method:

  T GetFirstChildOfType  (Dependent Object Scene) where T: dependency object {v Ar ItemCount = VisualTryHelper.GetChildNcount (view); if (item count <1) {return null;} for (int i = 0; i & lt; item count; i ++) {var dp = visuallytreehelper .Get chald (Visual, i); if (dp is t) {return (t) dp;}} for (int i = 0; i  

and get results in a similar way:

  zero item page Nmuna_loded (object sender, routing Aventarj e) {var item = Table = GetFirstChildOfType & lt; Panel & gt; (LB); }  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -