how to use multiple views in single GridColumn.

Hi Team,

I am working on WPF MVVM
I am using Syncfusion:SfDataGrid and I want to add two property in single syncfusion:GridTemplateColumn.CellTemplate column.

my sample code is given below :

<syncfusion:GridTemplateColumn MappingName="Check KRA Status" ShowHeaderToolTip="True" Width="100" syncfusion:FocusManagerHelper.WantsKeyInput="True">
                                <syncfusion:GridTemplateColumn.CellTemplate>
                                    <DataTemplate>

                                            <Button Content="Check KRA Status" ToolTip="Check KRA Status" syncfusion:FocusManagerHelper.FocusedElement="True"  Command="{Binding DataContext.OnPANStausRefresh,ElementName=dgKYCUser}" CommandParameter="{Binding}" />
                                   
         <!--<Hyperlink>-->
<!--<syncfusion:GridHyperlinkColumn>-->

                                    </DataTemplate>
                                </syncfusion:GridTemplateColumn.CellTemplate>
                            </syncfusion:GridTemplateColumn>


when I add Hyperlink  or  syncfusion:GridHyperlinkColumn on same DataTemplate the error appears as   
''The Property 'Visual Tree' is set more than once.

I want to use hyperlink on the same column and the row below the Button and that will bind to ViewModel.

The working should  be like first visbility of the hyperlink must be hidden and  after clicking on button
if some error gets on ViewModel the hyperlink should be shown on same row.

I didn't understand what to use Hyperlink or  syncfusion:GridHyperlinkColumn  and how it will get binded to ViewModel.

please help me with this,

Thank You.


1 Reply 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team July 10, 2020 04:12 PM UTC

Hi Devendragrv13,

Thank you for contacting Syncfusion support.

Your Requirement can be achieved by using Hyperlink inside GridTemaplateColumn. Please refer the below code snippet,

 
XAML Code Snippet: 
 
<syncfusion:GridTemplateColumn HeaderText="CustomerName" MappingName="CustomerName" > 
                    <syncfusion:GridTemplateColumn.CellTemplate> 
                        <DataTemplate> 
                            <StackPanel> 
                            <Button x:Name="btnContent"  Content="{Binding CustomerName}"  Width="100" Height="50" syncfusion:FocusManagerHelper.FocusedElement="True" 
                     Command="{Binding Path=DataContext.RowDataCommand,ElementName=sfDataGrid}"  
                     CommandParameter="{Binding ElementName=hyperlink}"/> 
                                <TextBlock  x:Name="hyperlink" HorizontalAlignment="Center" Visibility="Collapsed"> 
                                <Hyperlink  >Link</Hyperlink> 
                            </TextBlock> 
                              </StackPanel> 
                        </DataTemplate> 
                    </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 
 
C# Code Snippet: 
public void ChangeCanExecute(object obj) 
        { 
      //Button Clicked when Hyperlink show below Button 
            var textBlock = (obj as TextBlock); 
            if(textBlock.Visibility == Visibility.Collapsed) 
                textBlock.Visibility = Visibility.Visible;  
        } 
 

We hope this helps. Please let us know, if you require further assistance on this. 
 
Regards,
Vijayarasan S
 


Marked as answer
Loader.
Up arrow icon