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:
This works ok. The problem comes, for example, when I try to assing a tooltip:
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.