In code i add columns to listview successfuly. But i want add binding to column than add to listview.
fist is working code in xaml.
<GridViewColumn x:Name="colName" Header="Name" Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Values, Converter={StaticResource LoadProfileConverter},ConverterParameter=active_total}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Code behind:
GridViewColumn column = new GridViewColumn();
column.Header = "Header";
column.Width = 130;
FrameworkElementFactory controlFactory = new FrameworkElementFactory(typeof(TextBlock));
var itemsBinding = new System.Windows.Data.Binding("Values")
{
Converter = new LoadProfileConverter(),
ConverterParameter = "active_total",
};
controlFactory.SetBinding(TextBox.TextProperty, itemsBinding);
DataTemplate template = new DataTemplate();
template.VisualTree = controlFactory;
column.CellTemplate = template;
LoadProfileGrid.Columns.Add(column);
var itemsbinding = new Binding("Values")
{
Converter = new LoadProfileConverter(),
ConverterParameter = key
};
controllerFactory.SetBinding(TextBox.TextProperty, itemsbinding);
Create a proper binding using the code above.
Loads of extra properties on the binding object that can assist you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With