This question is locked. New answers and comments are not allowed.
Hey
I try to convert the following code from C# to VB.NET
This ends with a code conversion, which is not useable in VB.NET because the DependencyProperty is "new PropertyMetaData(OnSourceChanged) can't be executed in VB.NET but an AddHandler does not solve the problem, because the VB.NET translated code doesn n ot fire "OnSourceChanged"
THX
I try to convert the following code from C# to VB.NET
public
static
class
Navigator
{
public
static
INavigable GetSource(DependencyObject obj)
{
return
(INavigable)obj.GetValue(SourceProperty);
}
public
static
void
SetSource(DependencyObject obj, INavigable value)
{
obj.SetValue(SourceProperty, value);
}
public
static
readonly
DependencyProperty SourceProperty =
DependencyProperty.RegisterAttached(
"Source"
,
typeof
(INavigable),
typeof
(Navigator),
new
PropertyMetadata(OnSourceChanged));
private
static
void
OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Page page = (Page)d;
page.Loaded += PageLoaded;
}
private
static
void
PageLoaded(
object
sender, RoutedEventArgs e)
{
Page page = (Page)sender;
INavigable navSource = GetSource(page);
if
(navSource !=
null
)
{
navSource.NavigationService =
new
NavigationService(page.NavigationService);
}
}
}
This ends with a code conversion, which is not useable in VB.NET because the DependencyProperty is "new PropertyMetaData(OnSourceChanged) can't be executed in VB.NET but an AddHandler does not solve the problem, because the VB.NET translated code doesn n ot fire "OnSourceChanged"
THX