使用Telerik的RadListView和IncrementalLoadingMode ="明确",然后"加载更多的项目"即使列表视图实例中没有项目,按钮也始终可见。
有没有办法隐藏"加载更多项目"没有物品时按钮?没有物品时按钮就没有意义
答案 0 :(得分:0)
“加载更多项目”实际上是Telerik中的DataGridLoadDataControl
,您可以尝试通过VisualTreeHelper
在UI可视化树中找到它,然后将其设置为不可见。例如(grid是RadDataGrid
控件的名称):
private void btnloadcompleted_Click(object sender, RoutedEventArgs e)
{
IEnumerable<DataGridLoadDataControl> items = FindVisualChildren<DataGridLoadDataControl>(grid);
foreach (DataGridLoadDataControl item in items)
{
item.Visibility = Visibility.Collapsed;
}
}
private static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject
{
if (depObj != null)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(depObj, i);
if (child != null && child is T)
{
yield return (T)child;
}
foreach (T childOfChild in FindVisualChildren<T>(child))
{
yield return childOfChild;
}
}
}
}