Answer the question
In order to leave comments, you need to log in
How to pass the type of the associated element to the converter (converter)?
Hello!
There is a DataGrid, the data source for which changes during execution. Code for illustration:
// Один из типов
public class Foo
{
public string Id {get; set;}
public string Data {get; set;}
}
// Другой тип с другим набором полей и их типов
public class Bar
{
public int Code {get; set;}
public string OtherData {get; set;}
}
// Позже...
// Имеем два (или более) различных источников данных для одного и того же DataGrid
List<Foo> fooList = new List<Foo> { new Foo() { Id="ABC", Data = "data1" }}
List<Bar> barList = new List<Bar> { new Bar() { Code=3, OtherData = "data2" }}
// Переключаем источники
if (condition)
this.dgDisplay.ItemsSource = fooList;
else
this.dgDisplay.ItemsSource = barList;
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Content" Value="{Binding ConverterParameter=????, Converter={StaticResource PropertyDescriptionConverter}}" />
</Style>
</DataGrid.ColumnHeaderStyle>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question