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
225
xamDataPresenter bind button on grid to command
posted

i have this in my view model:

 

 

DelegateCommand _test;

        public ICommand TestCommand

        {

            get

            {

                if (_test == null)

                {

                    _test = new Commands.DelegateCommand(

                       () => this.Test(),

                       () => this.CanTest);

                }

                return _test;

            }

        }

        public void Test()

        {

        }

        public bool CanTest { get { return true; } }

 

 

in my View... i have:

 

<igDP:XamDataPresenter.Resources>

 

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

                    <Grid Width="16" Height="16">

                        <Rectangle Visibility="Collapsed" Fill="#FFBBBBBB" HorizontalAlignment="Left" Margin="0,1,0,0" x:Name="LeftBorder" VerticalAlignment="Center" Width="1"/>

                        <Border Margin="0,0,1,0" x:Name="MainBorder" Grid.Row="0" Background="#fff" BorderBrush="#fff" BorderThickness="0" CornerRadius="1,1,1,1"/>

                        <Button Margin="0,0,0,0" 

                                HorizontalAlignment="Left"

                                VerticalAlignment="Center"

                                Command="{Binding Path=TestCommand}"

                                Content="buttonText" />

                    </Grid>

                </ControlTemplate>

 

 

 

<Style x:Key="ButtonPresenter" TargetType="{x:Type igDP:CellValuePresenter}">

                    <Style.Triggers>

                        <DataTrigger Binding="{Binding TestValue}" Value="Test">

                            <Setter Property="Template" Value="{StaticResource ButtonTemplate}" />

                        </DataTrigger>

 

                    </Style.Triggers>

</Style>

 

and in the field layout, i have this:

 

<igDP:UnboundField Label="">

                        <igDP:Field.Settings>

                            <igDP:FieldSettings 

                                CellValuePresenterStyle="{StaticResource ButtonPresenter}" 

                                AllowResize="False"

                                CellMinWidth="16"

                                CellMaxWidth="16"

                                CellWidth="16"

                                LabelMinWidth="16"

                                LabelMaxWidth="16"

                                LabelWidth="16"

                                LabelHeight="0" />

                        </igDP:Field.Settings>

                    </igDP:UnboundField>

 

I get this error:

System.Windows.Data Error: 39 : BindingExpression path error: 'TestCommand' property not found on 'object' ''DataRecord' (HashCode=58216665)'. BindingExpression:Path=TestCommand; DataItem='DataRecord' (HashCode=58216665); target element is 'Button' (Name=''); target property is 'Command' (type 'ICommand')

I have also tried setting the relative source to itself, the TemplatedParent, and even the XamDataPresenter but all give the same error.  

 

I'm just trying to get my button to fire the command.  Any help?

 

 

 

Parents Reply Children
No Data