Thursday 17 March 2011

Silverlight: Dynamically binding the converter through code behind


Have a grid in the xaml/code behind.

Then proceed as shown below....!

Caution: DO NOT SEND PARAMETER WHEN CREATING BINDING OBJECT. IF YOU DO IT THE DYNAMIC BINDING WITH COLLECTIONS WILL NOT WORK.




dgBonus.Columns.Add(
                    new DataGridTextColumn
                    {
                        Header = columnName,
                        Binding = new Binding()
                        {
                            Converter = new RowIndexConverter(),
                            ConverterParameter = columnName
                        }
                    });

HOPE IT IS HELPFUL!!!....

2 comments: