I found very promising code online and I'd like to try it out.
Since my project is written in VB.net
and the code in question is in C#
I started to translate the bits and pieces I need to VB.net.
I'm done with translating, but I can't figure out what exactly one specific line of code does and how to translate that to VB.net.
And I'm out of ideas how to phrase a search for google to maybe find an answer myself.
So maybe you can shed some light on the mystics of C#?
Here's the C# source code (stripped down to the relevant bits):
public class TestClass
{
private ListView listView;
public TestClass(ListView input)
{
this.listView = input;
this.listView.Loaded += new RoutedEventHandler(ListViewLoaded);
this.listView.Unloaded += new RoutedEventHandler(ListViewUnloaded);
}
public static readonly DependencyProperty EnabledProperty = DependencyProperty.RegisterAttached(
"Enabled",
typeof(bool),
typeof(TestClass),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnEnabledChanged)));
private static void OnEnabledChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
ListView input = obj as ListView;
new TestClass(input); // <== this is the mystic line
}
}
I'm struggling with the last line of code in the static procedure OnEnabledChanged
. It looks like the constructor of this class is called but the result isn't assigned to anything.
Translating that to VB.net to just New TestClass(input)
results in an syntax error.
I tried a few automatic translators on the internet but they only return New TestClass(input)
, so they're as smart (or unknowing) as I am.
So can you tell me what this line of code does so that I can translate that to working VB.net?