Unclear how to cleanly implement Search (in XAML with MVVM bindings)

Documentation on this is quite sparse, with only out-of-context C#-implementation examples given like below:

```
this.dataGrid.SearchController.AllowFiltering = true;
this.dataGrid.SearchController.Search(entry.Text);
```

But I'm expecting to be able to do something like this in XAML:
```

            <datagrid:SfDataGrid.SearchController>

                <datagrid:DataGridSearchController

                    AllowCaseSensitive="False"

                    AllowFiltering="True"

                    CanHighlightSearchText="True"

                    SearchText="{Binding SearchText, Mode=TwoWay}"

                    SearchType="Contains" />

            </datagrid:SfDataGrid.SearchController>
```

But this gives an error:

Type 'DataGridSearchController' is not usable as an object element because it is not public or does not define a public parameterless constructor or a type converter.

Meanwhile, documentation screenshots show a neatly styled search-bar with all the bells and whistles (next,previous,clear) above the grid, but it's not even clear to me whether this is a built-in control or something I have to create myself.. 

Further guidance on how to actually use this feature would be much appreciated!


5 Replies 1 reply marked as answer

MM Muthukumar Madasamy Syncfusion Team December 8, 2025 02:35 PM UTC

Hi Jack,


Thank you for reaching out to us.


We understand your requirement to implement the search functionality in SfDataGrid using XAML and MVVM bindings. Currently, the DataGridSearchController cannot be declared in XAML because it does not expose a public parameterless constructor or a type converter. The error you encountered is expected behavior since the SearchController is an internal service object used by the grid for programmatic operations.


To achieve the search functionality, you will need to use the SearchController in code-behind or through MVVM-friendly approaches (such as behaviors or property-changed logic).


Please let us know if you need any further assistance.


Best Regards,
Muthu Kumar Madasamy.



JS Jack S. December 8, 2025 05:19 PM UTC

Thank you for your reply,

Given that the DataGrid's Search-functionality currently cannot be set through XAML, would you know of any full code samples that first define the DataGrid in XAML and then configure Search in one of the ways you mentioned?

I couldn't find any examples of this being used in MAUI, which doesn't help my understanding.

Another unanswered question would be about the search-bar itself (taken from docs):
Image_7317_1765214186062

Is this part of the DataGrid-control once Search is correctly configured, or am I expected to create such a control myself?

Kind regards,

Jack



MM Muthukumar Madasamy Syncfusion Team December 9, 2025 01:33 PM UTC

Hi Jack,

Thank you for your follow-up.

The search bar shown in the documentation is not built-in with SfDataGrid. It is a custom UI element (like an Entry or SearchBar) placed above the grid, and the search operation is handled using the grid’s SearchController in code-behind or through MVVM logic.

We have prepared a simple sample demonstrating this use case of searching.
If you have any questions or need further assistance, please feel free to reach out. We are happy to help.

Best Regards,
Muthu Kumar Madasamy.

Attachment: DataGridSearchingSample_8ce3fd6b.zip

Marked as answer

JS Jack S. replied to Muthukumar Madasamy December 10, 2025 02:23 PM UTC

Hi Muthukumar,

Very insightful answer, and the included sample is very helpful as well!

Based on your sample I have successfully got this working through MVVM (by passing the SfDataGrid instance to the ViewModel through the code-behind).

That setup is not as intuitive as I would have hoped, but once it's configured it works robustly and that's what counts.

Thank you very much!

Kind regards,

Jack



MM Muthukumar Madasamy Syncfusion Team December 11, 2025 06:09 AM UTC

Hi Jack,

We are glad to know that the reported scenario has been successfully resolved at your end and that the MVVM approach is working robustly for you.

Please let us know if you have any further questions or need assistance with additional features or optimizations. We are always happy to help!

Best Regards,
Muthu Kumar Madasamy

Loader.
Up arrow icon