Skip to content

Commit dd7413e

Browse files
Updated the Emptyview template UG topic
1 parent 799520e commit dd7413e

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

MAUI/TreeView/empty-view.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,63 @@ treeView.EmptyView = new Border
7979
N> The view displayed by the `EmptyView` can be a single view or a view that includes multiple child views.
8080

8181
![EmptyView in .NET MAUI TreeView](images/empty-view/maui-treeview-empty-view.gif)
82+
83+
## Empty view customization
84+
85+
The `SfTreeView` control allows you to fully customize the empty view appearance by using the `EmptyViewTemplate` property. This property lets you define a custom view and style for the `EmptyView`.
86+
87+
{% tabs %}
88+
{% highlight xaml hl_lines="11" %}
89+
<SearchBar x:Name="filterText"
90+
Placeholder="Search here"
91+
TextChanged="filterText_TextChanged" />
92+
<syncfusion:SfTreeView x:Name="treeView"
93+
ItemsSource="{Binding FilteredFolders}"
94+
AutoExpandMode="AllNodesExpanded"
95+
NotificationSubscriptionMode="CollectionChange">
96+
<syncfusion:SfTreeView.EmptyView>
97+
<local:FilterItem Filter="{Binding Source={x:Reference filterText},Path=Text}" />
98+
</syncfusion:SfTreeView.EmptyView>
99+
<syncfusion:SfTreeView.EmptyViewTemplate>
100+
<DataTemplate>
101+
<Border>
102+
....
103+
</Border>
104+
</DataTemplate>
105+
</syncfusion:SfTreeView.EmptyViewTemplate>
106+
</syncfusion:SfTreeView>
107+
108+
{% endhighlight %}
109+
{% highlight c# hl_lines="22" %}
110+
111+
SearchBar filterText = new SearchBar
112+
{
113+
Placeholder = "Search here"
114+
};
115+
filterText.TextChanged += FilterText_TextChanged;
116+
117+
SfTreeView treeView = new SfTreeView
118+
{
119+
AutoExpandMode = AutoExpandMode.AllNodesExpanded,
120+
NotificationSubscriptionMode = NotificationSubscriptionMode.CollectionChange
121+
};
122+
treeView.ItemsSource = viewModel.FilteredFolders;
123+
124+
var filterItem = new FilterItem
125+
{
126+
BindingContext = filterText
127+
};
128+
filterItem.SetBinding(FilterItem.FilterProperty, "Text");
129+
130+
treeView.EmptyView = filterItem;
131+
132+
treeView.EmptyViewTemplate = new DataTemplate(() =>
133+
{
134+
return new Border
135+
{
136+
...
137+
};
138+
});
139+
140+
{% endhighlight %}
141+
{% endtabs %}

0 commit comments

Comments
 (0)