How to binding ViewModel's SearchText variable to the DataGrid Cell as a converter parameter?

EdgeMac 20 Reputation points
2024-09-11T08:59:17.1733333+00:00

I've an other question: How to binding ViewModel's SearchText variable to the DataGrid Cell as a converter parameter. I'm using a converter to change ViewModel's list's field name: "content" to highlightedText textBlock. but the Convert method can't get the ViewModel's SearchText variable. parameter is null here.

public object Convert(object value, Type targetType, object parameter, string language)
{
   // parameter is null here.
   var searchText = parameter
}
 <localGrid:DataGridTemplateColumn Header="Content">
     <localGrid:DataGridTemplateColumn.CellTemplate>
         <DataTemplate>
              <ContentPresenter Content="{Binding Path=Content, 
                         Converter={StaticResource HighlightTextConverter}, 
                         ConverterParameter={Binding ElementName=EditPage, Path=ViewModel.SearchText}}"/>
         </DataTemplate>
     <localGrid:DataGridTemplateColumn.CellTemplate>
<localGrid:DataGridTemplateColumn>

Windows development | Windows App SDK
Developer technologies | .NET | .NET MAUI
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | .NET | Other
Developer technologies | C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.