Skip to content

Commit 53f3940

Browse files
Update the README.md file
1 parent 3b0fa2b commit 53f3940

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,69 @@
1+
# hide-checkbox-treeview-xamarin
2+
How to conditionally hide the checkbox in Xamarin.Forms TreeView (SfTreeView)
3+
14
**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12142/how-to-conditionally-hide-the-checkbox-in-xamarin-forms-treeview-sftreeview)**
5+
6+
## Sample
7+
8+
### XAML
9+
Bind the SfCheckBox.IsVisible property with TreeViewNode.Level and define converter to handle the Visibility.
10+
```xaml
11+
<treeView:SfTreeView x:Name="treeView"
12+
ItemTemplateContextType="Node"
13+
CheckBoxMode="Recursive"
14+
AutoExpandMode="RootNodesExpanded"
15+
CheckedItems="{Binding CheckedItems}"
16+
ItemsSource="{Binding Folders}">
17+
<treeView:SfTreeView.HierarchyPropertyDescriptors>
18+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:Folder}" ChildPropertyName="SubFolder"/>
19+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:SubFolder}" ChildPropertyName="Files"/>
20+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:File}" ChildPropertyName="SubFiles"/>
21+
</treeView:SfTreeView.HierarchyPropertyDescriptors>
22+
23+
<treeView:SfTreeView.ItemTemplate>
24+
<DataTemplate>
25+
<Grid Padding="5">
26+
<Grid.ColumnDefinitions>
27+
<ColumnDefinition Width="40"/>
28+
<ColumnDefinition Width="*"/>
29+
</Grid.ColumnDefinitions>
30+
<checkBox:SfCheckBox x:Name="CheckBox" IsChecked="{Binding IsChecked, Mode=TwoWay}" CornerRadius="2" IsVisible="{Binding Level, Converter={StaticResource checkBoxVisibilityConverter}}"/>
31+
<Label Text="{Binding Content.FileName}" VerticalOptions="CenterAndExpand" HorizontalOptions="StartAndExpand" Grid.Column="1"/>
32+
</Grid>
33+
</DataTemplate>
34+
</treeView:SfTreeView.ItemTemplate>
35+
</treeView:SfTreeView>
36+
```
37+
38+
### Converter
39+
```csharp
40+
public class CheckBoxVisibilityConverter : IValueConverter
41+
{
42+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
43+
{
44+
return (int)value == 0 ? false : true;
45+
}
46+
}
47+
```
48+
49+
## Requirements to run the demo
50+
Visual Studio 2017 or Visual Studio for Mac.
51+
Xamarin add-ons for Visual Studio (available via the Visual Studio installer).
52+
53+
## Troubleshooting
54+
### Path too long exception
55+
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.
56+
57+
## License
58+
59+
Syncfusion® has no liability for any damage or consequence that may arise from using or viewing the samples. The samples are for demonstrative purposes. If you choose to use or access the samples, you agree to not hold Syncfusion® liable, in any form, for any damage related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion®'s samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion®'s samples.
60+
61+
## Conclusion
62+
63+
I hope you enjoyed learning about how to conditionally hide the checkbox in Xamarin.Forms TreeView (SfTreeView).
64+
65+
You can refer to our Xamarin.Forms TreeViewfeature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
66+
67+
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
68+
69+
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

0 commit comments

Comments
 (0)