VB.NET - Code conversion fron c# to vb.net - Asked By Gianfranco Vrech on 07-Aug-17 09:13 AM

Hi to all the ML.

I'v found an example in this site of code that I would like to use. It's written in c # and would like to convert it to vb.net.

The original code is : http://www.nullskull.com/a/10476706/xaml-datagrid-binding-data-columns-or-rows-dynamically-using-mvvm-design-pattern.aspx

The problem I found is in this sub:

private static DataGridTextColumn GetDataColumn(DataGridColumns columnName)
       var column = new DataGridTextColumn();
       column.IsReadOnly = true;
       column.Header = columnName.DisplayColumnName;
       column.Binding = new Binding();
       column.Binding.Converter = new ColumnValueConverter();
       column.Binding.ConverterParameter = columnName.BindingPropertyName;
       return column;

In vb.net should be written as follows:


Private Shared Function GetDataColumn(columnName As DataGridColumns) As DataGridTextColumn
    Dim column = New DataGridTextColumn()
    column.IsReadOnly = True
    column.Header = columnName.DisplayColumnName
    column.Binding = New System.Windows.Data.Binding()
    column.Binding.converter = New ColumnValueConverter
    column.Binding.ConverterParameter = columnName.BindingPropertyName
    Return column
  End Function

But I've some problems with the two lines beforte the return statement. Any ideas?

Robbe Morris replied to Gianfranco Vrech on 13-Aug-17 11:18 AM
The last two lines reference a custom class in that article.  You'll find it towards the bottom of the page.  I suspect you did not include that class in your code.
Gianfranco Vrech replied to Robbe Morris on 21-Aug-17 03:14 AM
The class to which it refers is in the same namespace. Import is not necessary.
Michael Newman replied to Gianfranco Vrech on 01-Sep-20 06:04 AM
Have you tried using the Telerik code converter.  A free online service.  Here is the link