Skip to content

Commit 050ccf4

Browse files
Merge pull request #2 from Santhosh-SF4792/main
Update the README.md file
2 parents 3b0fa2b + c5dae5c commit 050ccf4

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
1-
**[View document in Syncfusion Xamarin Knowledge base](https://www.syncfusion.com/kb/12142/how-to-conditionally-hide-the-checkbox-in-xamarin-forms-treeview-sftreeview)**
1+
# hide-checkbox-treeview-xamarin
2+
How to conditionally hide the checkbox in Xamarin.Forms TreeView (SfTreeView)
3+
4+
## Sample
5+
6+
### XAML
7+
Bind the SfCheckBox.IsVisible property with TreeViewNode.Level and define converter to handle the Visibility.
8+
```xaml
9+
<treeView:SfTreeView x:Name="treeView"
10+
ItemTemplateContextType="Node"
11+
CheckBoxMode="Recursive"
12+
AutoExpandMode="RootNodesExpanded"
13+
CheckedItems="{Binding CheckedItems}"
14+
ItemsSource="{Binding Folders}">
15+
<treeView:SfTreeView.HierarchyPropertyDescriptors>
16+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:Folder}" ChildPropertyName="SubFolder"/>
17+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:SubFolder}" ChildPropertyName="Files"/>
18+
<treeViewEngine:HierarchyPropertyDescriptor TargetType="{x:Type local:File}" ChildPropertyName="SubFiles"/>
19+
</treeView:SfTreeView.HierarchyPropertyDescriptors>
20+
21+
<treeView:SfTreeView.ItemTemplate>
22+
<DataTemplate>
23+
<Grid Padding="5">
24+
<Grid.ColumnDefinitions>
25+
<ColumnDefinition Width="40"/>
26+
<ColumnDefinition Width="*"/>
27+
</Grid.ColumnDefinitions>
28+
<checkBox:SfCheckBox x:Name="CheckBox" IsChecked="{Binding IsChecked, Mode=TwoWay}" CornerRadius="2" IsVisible="{Binding Level, Converter={StaticResource checkBoxVisibilityConverter}}"/>
29+
<Label Text="{Binding Content.FileName}" VerticalOptions="CenterAndExpand" HorizontalOptions="StartAndExpand" Grid.Column="1"/>
30+
</Grid>
31+
</DataTemplate>
32+
</treeView:SfTreeView.ItemTemplate>
33+
</treeView:SfTreeView>
34+
```
35+
36+
### Converter
37+
```csharp
38+
public class CheckBoxVisibilityConverter : IValueConverter
39+
{
40+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
41+
{
42+
return (int)value == 0 ? false : true;
43+
}
44+
}
45+
```
46+
47+
## Requirements to run the demo
48+
49+
To run the demo, refer to [System Requirements for Xamarin](https://help.syncfusion.com/xamarin/system-requirements)
50+
51+
## Troubleshooting
52+
### Path too long exception
53+
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.

0 commit comments

Comments
 (0)