0

This is my view code sample,

<DataGrid Margin="0,0,0,0" Name="gdProcessDetails" ItemsSource="{Binding AttachmentList}" >                    
                    <DataGrid.Columns>
                    <DataGridTemplateColumn Width="670"  IsReadOnly="True" x:Name="btnMemeberDelete" MaxWidth="670" Selector.IsSelected="True">
                            <DataGridTemplateColumn.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock Text="Attach File"  Width="650" TextWrapping="Wrap" FontFamily="Arial Unicode MS" FontSize="16" TextAlignment="Center" FontWeight="Bold" />
                                </DataTemplate>
                            </DataGridTemplateColumn.HeaderTemplate>
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" Margin="0,2" Width="670"  Height="40">
                                        <Border BorderBrush="#FF8D7C7C" BorderThickness="1">
                                            <TextBlock Name="txtFilePath" Text="{Binding UploadedFileName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Height="32" FontSize="16" FontFamily="Arial Unicode MS" Margin="10,0,5,0" MinWidth="500" MaxWidth="500" />
                                        </Border>
                                        <Button Height="32"  HorizontalAlignment="Center" Margin="5,5,0,0" Name="btnUploadDoc" VerticalAlignment="Top" Command="{Binding ElementName=CertificateControl, Path= DataContext.UploadDocCommand}" CommandParameter ="{Binding ElementName=btnUploadDoc}" MinWidth="80">
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="Browse" FontSize="16" FontFamily="Arial Unicode MS" Margin="0,0,5,0" MaxWidth="100" TextWrapping="Wrap" />
                                            </StackPanel>
                                        </Button>                                            
                                    </StackPanel>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>         
                </DataGrid>

Data context of this View has 'UploadDocCommand' Icommand property. This is working fine on most of the machine. But on few laptops, clicking on this button does nothing. Any help would be much appreciated. Same result on all over the application wherever Buttons are used inside DataGrid/toolkit:DataGrid. Thanks in advance.

UPDATE : Happens only on 4.0 framework machine

Siva
  • 23
  • 5
  • If you're using RelayCommand, [this topic](http://stackoverflow.com/questions/16857547/relaycommand-not-firing-on-some-computers) could be helpfull – Fragment Feb 12 '16 at 10:53
  • Thanks for your quick response. Yes, RelayCommand is used all over the application to bind ICommand. Normal buttons which are outside DataGrid works fine on these same laptop. – Siva Feb 12 '16 at 10:58
  • Because they're utter crap laptops and the click event was never registered? Who could *possibly* know? –  Feb 12 '16 at 13:45
  • Maybe try to update the .NET/CLR version on those laptops. – aniski Feb 12 '16 at 20:56
  • This issue happens only on Framework 4.0 machine. To run this code need 4.5 framework seems. Unfortunately, we can not force all the users to install 4.5 framework for this, but i have used this logic more number of places in my project. It would be much appreciated if anyone can give any ideas.. – Siva Feb 18 '16 at 10:58

1 Answers1

0

This issue was happening only with Framework 4.0. I have fixed this using RelativeSource instead of ElementName. Changed the button Command property as below and worked. Thanks for all your help.

<Button Height="32"  HorizontalAlignment="Center" Margin="5,5,0,0" Name="btnUploadDoc" VerticalAlignment="Top" Command="{Binding DataContext.UploadDocCommand, RelativeSource={RelativeSource AncestorType=DataGrid}}" CommandParameter ="{Binding ElementName=btnUploadDoc}" MinWidth="80">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Browse" FontSize="16" FontFamily="Arial Unicode MS" Margin="0,0,5,0" MaxWidth="100" TextWrapping="Wrap" />
                                        </StackPanel>
                                    </Button> 
Siva
  • 23
  • 5