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
1070
CellValuePresenter Button with Command
posted

I have a style that puts a button in an UnboundField of a row. The button calls the MyCommand method on MyClass. Everything works fine, except the Parameter to the event handler is null. I'd like to have the button do an expand all on all the child records, so I was hoping to get to the record that contains the CellValuePresenter, which is why I'm passng Record as the parameter.

Why is the record field null? What should I bind to so that I can iterate and expand child records of the buttons row?

                <Style x:Key="myStyle" TargetType="{x:Type igDP:CellValuePresenter}" BasedOn="{x:Static igThemes:DataPresenterGeneric.CellValuePresenter}">

                    <Setter Property="Template">

                        <Setter.Value>

                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                                <Button Content="+" HorizontalAlignment="Center" VerticalAlignment="Center"

                                        Command="local:MyClass.MyCommand"

                                        CommandParameter="{Binding Path=Record}"

                                        />

                            </ControlTemplate>

                        </Setter.Value>

                    </Setter>

                </Style>

Parents
  • 69686
    Verified Answer
    posted

    Hello,

    You should be getting an error showing that Record property cannot be found. This is because it will try to resolve it from the CellValuePresenter's DataContext which is the DataRecord. If you want this binding to find the recond, you need to set the RelativeSource to TemplatedParent or FindAncestor, AncestorType-CellValuePresenter.

    Also, you could consider binding directly to the DataPresenterBase.ExpanRecord command

Reply Children