public static void SearchVisualTree(DependencyObject targetElement, int width,string Node)
{
var count = VisualTreeHelper.GetChildrenCount(targetElement);

if (count == 0)
{
return;
}
for (int i = 0; i < count; i++)
{
var child = VisualTreeHelper.GetChild(targetElement, i);
if (child is TextBlock)
{
TextBlock targetItem = (TextBlock)child;
if (targetItem.Name == Node)
targetItem.Width = width;
}
else
{
SearchVisualTree(child, width,Node);
}
}
}

用法:DBHelper.SearchVisualTree(listboxname,300,"textBox1");

相关文章:

  • 2021-08-10
  • 2021-10-08
  • 2022-12-23
  • 2021-08-17
  • 2021-12-13
  • 2022-12-23
  • 2021-07-26
  • 2022-12-23
猜你喜欢
  • 2021-10-05
  • 2021-07-11
  • 2021-10-24
  • 2021-11-16
  • 2021-09-15
相关资源
相似解决方案