Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
339
CellValuePresenter Problem
posted

Hello,

I'm having problems implementing a custom template with the CellValuePresenter.

Inside my template I have a ContentControl control that I programmatically add my own controls to, based on the underlying cell's Data Record Data Item.

The problem is I can't find an elegant way of gaining a reference to the Cell I am dealing with, as at the CellValuePresenter level I can't see any exposed properties that provide this. The CVP does provide the DataContext (to provide the DataRecord) and the Field but when binding from XAML you can only pass in one property reference in the "Path" attribute :

<ContentControl Content="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                                  Path=DataContext,
                                                                  Converter={StaticResource textFormatterHelper} }" />

Ideally when binding I want to set the Path attribute value to the CellValuePrenter itself, so then I can get access to both the DataContext and Field, so I can get a reference to the Cell I'm trying to template.

As mentioned, I need access to the Data Record's Data Item and the Cell, so passing in the CVP's Value or Content properties is not sufficient with what I'm trying to do.

I'm quite new to WPF so there might be an easy solution to this!

Thanks,

Jamie