binding to radgridview's parent datacontext

3 posts, 0 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 07 Jun 2012 Link to this post

    I would like to know if it's possible for a  calculated column to access to the parent's context... I need to calulate over a parameter that's inside the main viewmodel..... I've tried to do 

    <telerik:GridViewDataColumn Header="Calculated Max"
                      DataMemberBinding="{Binding Converter={StaticResource calculatedColumnConverter},ConverterParameter={Binding RelativeSource={RelativeSource AncestorType= Grid}}}"></telerik:GridViewDataColumn>

    but I got an exception 

    {System.InvalidOperationException: Operation is not valid due to the current state of the object.
       at System.Windows.Data.BindingBase.CheckCanReceiveMarkupExtension(IProvideValueTarget provideValueTarget, DependencyObject& targetDependencyObject, DependencyProperty& targetDependencyProperty)
       at System.Windows.Data.BindingBase.ProvideValue(IServiceProvider serviceProvider)
       at MS.Internal.XamlManagedRuntimeRPInvokes.TryApplyMarkupExtensionValue(Object target, XamlPropertyToken propertyToken, Object& value)

    How can I do that?
  2. Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Jun 2012 Link to this post

    Hi Paolo,

    From within the cell you can get access to the row DataContext  rather than the original view model . For such cases as yours we strongly recommend to expose your view model as static resource and use binding to this static resource.

    All the best,
    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 07 Jun 2012 Link to this post

    Helo Pavel,
    thanks for your reply....I can't expose the viewmodel since I'm with Caliburn Micro.... so it resolves it automatically
    I'll try to put the value I need into the Datacontext's item...I don't like this but I cannot find another solution...
Back to Top