This is a migrated thread and some comments may be shown as answers.

UI Virtualization problem with Q1 2012 SP1

3 Answers 49 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 04 May 2016, 08:44 AM

Hi, I have a gridview that can have configurable colums. Some of them use the default template, but others not. I have a problem with the ones that need to show icons.

 

Here is a sample of a datatemplate of a GridViewCell:

 

<DataTemplate x:Key="IconFlagsCellTemplate">
    <StackPanel Name="IconFlagsCellTemplate" Orientation="Horizontal" DataContext="{Binding Blockings, Converter={StaticResource IconFlagsConverter}}">
        <Image Source="{StaticResource BlockingTechnicalOffice16x16}" Visibility="{Binding TechnicalOffice, Converter={StaticResource Boolean2VisibilityConverter}}"/>
 
 
    </StackPanel>
</DataTemplate>

 

This works ok. The problem comes, for example, when I try to assing a tooltip:

<DataTemplate x:Key="IconFlagsCellTemplate">
    <StackPanel Name="IconFlagsCellTemplate" Orientation="Horizontal" DataContext="{Binding Blockings, Converter={StaticResource IconFlagsConverter}}">
 
        <Image Source="{StaticResource BlockingTechnicalOffice16x16}" ToolTip="{lex:Loc BudgetBlockingTooltip_TECHNICAL_OFFICE}"
            Visibility="{Binding TechnicalOffice, Converter={StaticResource Boolean2VisibilityConverter}}"/>
 
    </StackPanel>
</DataTemplate>

I receive the next error when I scroll horizontally and the cell is going out of scope, the moment that I think the control will recycle the cell:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.FrameworkElement', AncestorLevel='1''. BindingExpression:Path=Parent; DataItem=null; target element is 'StackPanel' (Name='IconFlagsCellTemplate'); target property is 'Parent' (type 'DependencyObject')

 

Also this produces that the horizontal scroll pauses a little bit when giving those errors, causing a notieceable visual delay.

But there is more. I need the image to be wrapped into a button, as I need to add a contextual menu to the button and some triggers, but this also produces the avobe error, no matter if there is tooltip or not. Fortunately, if instead of the button I put a ContentControl, but not tooltip, there is no problem as well.

 

I need, though, both tooltip and custom menu. And also there is need to keep into account that there will not be only an icon. There could be any number of icons, that will be shown or not depending on some ViewModel condition, as you can see with the bindings.

 

Hope anybody could help me by providing a working solution, as the client is complaining about the scrolling issue. Meanwhile I'll try to test other ways of doing things.

 

Thanks in advance.

 

David.

 

 

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 04 May 2016, 09:57 AM

I've found an issue that allows me to use tooltips. I was using WPFLocalizationExtension, and some special markup for it. If instead of using it I do the translation in codebehind in the Load event of the image, I can set the tooltip without problem.

I will update this thread when I find a complete solution.

0
David
Top achievements
Rank 1
answered on 05 May 2016, 07:32 AM

Finally I could manage in doing what I wanted:

 

<ContentControl Style="{StaticResource CellIconContentControlStyle}" Tag="{x:Static model:BlockingFlags.TECHNICAL_OFFICE}"
    Visibility="{Binding TechnicalOffice, Converter={StaticResource Boolean2VisibilityConverter}}">
    <Image Style="{StaticResource CellIconContentImageStyle}" Loaded="IconImage_Loaded"
        Source="{StaticResource BlockingTechnicalOffice16x16}" Tag="BudgetBlockingTooltip_TECHNICAL_OFFICE"/>
</ContentControl>

 

Above is how I specify the icon inside the gridview. In the Loaded event the translation is done. I am using tag, but I think I will change it for tooltip in case I need tag in the future.

 

 

 

0
Yoan
Telerik team
answered on 05 May 2016, 01:52 PM
Hello,

I am glad to hear that you could resolve the problem by yourself. 

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or