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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Control visibility of checkbox in sfTreeView nodes

Thread ID:

Created:

Updated:

Platform:

Replies:

146949 Aug 26,2019 06:21 PM UTC Aug 30,2019 07:32 AM UTC Xamarin.Forms 4
loading
Tags: SfTreeView
Krunal
Asked On August 26, 2019 06:21 PM UTC

In sfTreeView, I'm showing checkbox in each node by adding following code in ItemTemplate

            <sfTreeView:SfTreeView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <Grid x:Name="grid" Padding="5" RowSpacing="0" BackgroundColor="Transparent">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <sfButton:SfCheckBox IsVisible="{Binding ShowCheckBox, Converter={StaticResource testConverter}}"
                                            x:Name="CheckBox"
                                            IsChecked="{Binding IsChecked, Mode=TwoWay}" 
                                            Text="{Binding Content.SubCategoryName}"
                                            TextColor="Black" 
VerticalOptions="Center"
                                            FontSize="{OnPlatform Android={OnIdiom Phone=16, Tablet=18},iOS={OnIdiom Phone=16,Tablet=18},UWP={OnIdiom Phone=18,Tablet=20,Desktop=20}}"/>
                                <Label Grid.Column="1" Text="{Binding Content.Price}" Margin="3" VerticalOptions="Center"/>
                            </Grid>
                        </ViewCell.View>
                    </ViewCell>

                </DataTemplate>
            </sfTreeView:SfTreeView.ItemTemplate>

Above code shows checkbox on both parent and child node in treeview. However, I want to show checkbox only on child nodes. I have added IsVisible binding as shown in above code but it doesn't control the visibility of checkboxes. How visibility of checkboxes can be controlled through binding?

Regards,


Sangeetha Raju [Syncfusion]
Replied On August 28, 2019 01:15 AM UTC

Hi Krunal, 
 
We would like to inform you that you can achieve your requirement by implementing the different templates using TemplateSelector. We have already updated in our documentation. Please find the documentation for further information. 
 
 
We have prepared a sample for you reference. Please find the sample from the below link. 
 
 
Can you please check with the above sample and let us know whether the provided solution meets your requirement.  
 
Regards, 
Sangeetha Raju. 


Krunal
Replied On August 29, 2019 06:29 AM UTC

@Sangeetha
Thanks for response with example.

I managed to set my treeview node view by following the example given by you. One issue I'm facing with it is IsChecked binding for the checkbox is not working (Template2.xaml) code. I also want to bind the checkbox with property in my viewmodel but upon check/uncheck, property value associated with binding is not updating. Can you pls check and revert back.

Thanks,

Krunal
Replied On August 29, 2019 07:23 AM UTC

I figured out the issue. ItemTemplateContextType was set to "Node" in my code. I changed it to "Item" and now checkbox binding works.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On August 30, 2019 07:32 AM UTC

Hi Krunal,   
   
Thank you for the update. We are happy that the mentioned issue resolved at your end.

Please get in touch with us, if you would require any further assistance.  
 
Regards,
Subburaj Pandian V  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon