We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataGrid Template Column Binding to Commands

Hi I have a GridTemplateColumn in a DataGrid into which I have a Button. In principle I have a column which may or may not have notes in it. I show a button to indicate a note and if there is a note I intend the user can click the button to show / edit the note. The Cell Template is shown below.

<syncfusion:GridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="" Visibility="{Binding Note,Converter={StaticResource stringToVisibilityConverter}}" 
                                    Margin="0,0,12,0"
                                    BorderBrush="Transparent"  FontFamily="Segoe UI Symbol" 
                                    FontSize="30" Foreground="Gold" 
                                    HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </DataTemplate>
                    </syncfusion:GridTemplateColumn.CellTemplate>

When I try and bind the button to a command the binding fails as it is looking within the Type which is bound to each row rather than the parent data context. What is the best way to achieve this?

1 Reply

NJ Narayanasamy J Syncfusion Team November 21, 2013 06:24 AM UTC

Hi Richard,

Thank you for using Syncfusion products,

We have analyzed your query. . You need to specify Source Property for Binding explicitly in UIElement.Visibility property to achieve your requirement. Please find the code snippet below for your reference:

Code Snippet:

 

<Button Content="[]" Visibility="{Binding Note,Source={StaticResource viewModel}}" Height="50"  Width="100"/>

         

Please let us know if you need further assistance.

Regards,

Narayanasamy.


Loader.
Live Chat Icon For mobile
Up arrow icon