Skip to content

Commit 7fd4276

Browse files
Addressed review comments
1 parent dd7413e commit 7fd4276

File tree

2 files changed

+48
-28
lines changed

2 files changed

+48
-28
lines changed

MAUI/TreeView/empty-view.md

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,57 +85,77 @@ N> The view displayed by the `EmptyView` can be a single view or a view that inc
8585
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`.
8686

8787
{% 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>
88+
{% highlight xaml hl_lines="14" %}
89+
<Grid RowDefinitions="Auto,*">
90+
<SearchBar x:Name="filterText"
91+
Placeholder="Search here"
92+
TextChanged="filterText_TextChanged" />
93+
<syncfusion:SfTreeView x:Name="treeView"
94+
ItemsSource="{Binding FilteredFolders}"
95+
AutoExpandMode="AllNodesExpanded"
96+
NotificationSubscriptionMode="CollectionChange"
97+
Grid.Row="1">
98+
<syncfusion:SfTreeView.EmptyView>
99+
<local:FilterItem Filter="{Binding Source={x:Reference filterText}, Path=Text}" />
100+
</syncfusion:SfTreeView.EmptyView>
101+
102+
<syncfusion:SfTreeView.EmptyViewTemplate>
100103
<DataTemplate>
101-
<Border>
102-
....
103-
</Border>
104+
<Border>
105+
....
106+
</Border>
104107
</DataTemplate>
105-
</syncfusion:SfTreeView.EmptyViewTemplate>
106-
</syncfusion:SfTreeView>
108+
</syncfusion:SfTreeView.EmptyViewTemplate>
109+
</syncfusion:SfTreeView>
110+
</Grid>
107111

108112
{% endhighlight %}
109-
{% highlight c# hl_lines="22" %}
113+
{% highlight c# hl_lines="34" %}
110114

111-
SearchBar filterText = new SearchBar
115+
var grid = new Grid();
116+
grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
117+
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
118+
119+
var filterText = new SearchBar
112120
{
113121
Placeholder = "Search here"
114122
};
115123
filterText.TextChanged += FilterText_TextChanged;
116124

117-
SfTreeView treeView = new SfTreeView
125+
// Add SearchBar to Grid (Row 0)
126+
grid.Children.Add(filterText);
127+
Grid.SetRow(filterText, 0);
128+
129+
var treeView = new SfTreeView
118130
{
131+
ItemsSource = viewModel.FilteredFolders,
119132
AutoExpandMode = AutoExpandMode.AllNodesExpanded,
120133
NotificationSubscriptionMode = NotificationSubscriptionMode.CollectionChange
121134
};
122-
treeView.ItemsSource = viewModel.FilteredFolders;
123135

124-
var filterItem = new FilterItem
125-
{
126-
BindingContext = filterText
127-
};
128-
filterItem.SetBinding(FilterItem.FilterProperty, "Text");
136+
Grid.SetRow(treeView, 1);
137+
grid.Children.Add(treeView);
129138

139+
var filterItem = new FilterItem();
140+
filterItem.SetBinding(FilterItem.FilterProperty, new Binding
141+
{
142+
Source = filterText,
143+
Path = "Text"
144+
});
130145
treeView.EmptyView = filterItem;
131146

147+
// Define the EmptyViewTemplate
132148
treeView.EmptyViewTemplate = new DataTemplate(() =>
133149
{
134150
return new Border
135151
{
136-
...
152+
...
137153
};
138154
});
139155

140156
{% endhighlight %}
141157
{% endtabs %}
158+
159+
N>
160+
* The `EmptyViewTemplate` will only be applied when the `EmptyView` property is explicitly defined. If `EmptyView` is not set, the template will not be displayed.
161+
* `EmptyView` can be set to custom data model and the appearance of the `EmptyView` can be customized by using the `EmptyViewTemplate`.

maui-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@
13791379
<li><a href="/maui/TreeView/sorting">Sorting</a></li>
13801380
<li><a href="/maui/TreeView/mvvm">MVVM</a></li>
13811381
<li><a href="/maui/TreeView/load-on-demand">Load on Demand</a></li>
1382-
<li><a href="/maui/TreeView/empty-view">Empty view</a></li>
1382+
<li><a href="/maui/TreeView/empty-view">Empty View</a></li>
13831383
<li><a href="/maui/TreeView/item-height-customization">Item Height Customization</a></li>
13841384
<li><a href="/maui/TreeView/right-to-left">Right to left</a></li> </ul>
13851385
</li>

0 commit comments

Comments
 (0)