Hi,
I am just trying to improve scroll performance, when the RowDetailsVisibilityMode is set to "Visible", because it is slow for complex detail controls.
Now I am doing this:
<DataTemplate x:Key="DetailTemplate">
<ContentControl/>
</DataTemplate>
In code behind:
List<TextBlock> notInUse = new List<TextBlock>();
public DataListEditor()
{
InitializeComponent();
for (int i = 0; i < 100; ++i)
{
TextBlock tb = new TextBlock();
notInUse.Add(tb);
}
dataListGrid.LoadingRowDetails += dataListGrid_LoadingRowDetails;
dataListGrid.UnloadingRowDetails += dataListGrid_UnloadingRowDetails;
}
void dataListGrid_UnloadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
ContentControl c = e.DetailsElement as ContentControl;
TextBlock tb = c.Content as TextBlock;
if (tb != null)
{
c.Content = null;
notInUse.Add(tb);
}
}
void dataListGrid_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
ContentControl c = e.DetailsElement as ContentControl;
if (c.Content == null)
{
Binding b = new Binding("Roles[0].DisplayName");
b.Source = e.Row.DataContext;
TextBlock tb = notInUse[0];
notInUse.RemoveAt(0);
tb.SetBinding(TextBlock.TextProperty, b);
c.Content = tb;
}
}
In other words: I try to recycle detail controls, so that there is no need to recreate them. This works fine, when I am only scrolling. But if I resize the window, the DetailsPresenter of a row seems not to be measured to its content, so the text block is there with the right height, but its visual ancestors have a wrong height and the textblock is not visible. Is there a workaround to solve this?
Thanks
I am just trying to improve scroll performance, when the RowDetailsVisibilityMode is set to "Visible", because it is slow for complex detail controls.
Now I am doing this:
<DataTemplate x:Key="DetailTemplate">
<ContentControl/>
</DataTemplate>
In code behind:
List<TextBlock> notInUse = new List<TextBlock>();
public DataListEditor()
{
InitializeComponent();
for (int i = 0; i < 100; ++i)
{
TextBlock tb = new TextBlock();
notInUse.Add(tb);
}
dataListGrid.LoadingRowDetails += dataListGrid_LoadingRowDetails;
dataListGrid.UnloadingRowDetails += dataListGrid_UnloadingRowDetails;
}
void dataListGrid_UnloadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
ContentControl c = e.DetailsElement as ContentControl;
TextBlock tb = c.Content as TextBlock;
if (tb != null)
{
c.Content = null;
notInUse.Add(tb);
}
}
void dataListGrid_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
{
ContentControl c = e.DetailsElement as ContentControl;
if (c.Content == null)
{
Binding b = new Binding("Roles[0].DisplayName");
b.Source = e.Row.DataContext;
TextBlock tb = notInUse[0];
notInUse.RemoveAt(0);
tb.SetBinding(TextBlock.TextProperty, b);
c.Content = tb;
}
}
In other words: I try to recycle detail controls, so that there is no need to recreate them. This works fine, when I am only scrolling. But if I resize the window, the DetailsPresenter of a row seems not to be measured to its content, so the text block is there with the right height, but its visual ancestors have a wrong height and the textblock is not visible. Is there a workaround to solve this?
Thanks