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>

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,934 questions
Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
798 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,624 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,038 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,959 questions
{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.