Problem bei Übersetztung C# -> VB: DependencyProperty

  • WPF

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Artentus.

    Problem bei Übersetztung C# -> VB: DependencyProperty

    Hallo,
    ich weiß nicht, ob das schon zu WPF gehört, aber ich habe die Frage trotzdem mal hier gestellt, da es eig. nur ums Übersetzten geht. Ich habe folgendes im Netz gefunden: weblogs.asp.net/marianor/archi…dows-form-notifyicon.aspx
    Das ist C#, also habe ich angefangen alles zu übersetzten. Doch jetzt hänge ich hier fest:
    Spoiler anzeigen

    Quellcode

    1. public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
    2. "Icon",
    3. typeof(ImageSource),
    4. typeof(NotifyIcon),
    5. new FrameworkPropertyMetadata(OnIconChanged));
    6. public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
    7. "Text",
    8. typeof(string),
    9. typeof(NotifyIcon),
    10. new PropertyMetadata(OnTextChanged));
    11. private static void OnTextChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
    12. {
    13. NotifyIcon control = (NotifyIcon)target;
    14. control.notifyIcon.Text = control.Text;
    15. }
    16. private static void OnIconChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
    17. {
    18. if (!DesignerProperties.GetIsInDesignMode(target))
    19. {
    20. NotifyIcon control = (NotifyIcon)target;
    21. control.notifyIcon.Icon = FromImageSource(control.Icon);
    22. }
    23. }


    Das habe ich so übersetzt:

    VB.NET-Quellcode

    1. Public Shared ReadOnly IconProperty As DependencyProperty = DependencyProperty.Register("Icon", GetType(ImageSource), GetType(NotifyIcon), New FrameworkPropertyMetadata(OnIconChanged))
    2. Public Shared ReadOnly TextProperty As DependencyProperty = DependencyProperty.Register("Text", GetType(String), GetType(NotifyIcon), New PropertyMetadata(OnTextChanged))
    3. Private Shared Sub OnTextChanged(target As DependencyObject, e As DependencyPropertyChangedEventArgs)
    4. Dim control As NotifyIcon = DirectCast(target, NotifyIcon)
    5. control.notifyIcon.Text = control.Text
    6. End Sub
    7. Private Shared Sub OnIconChanged(target As DependencyObject, e As DependencyPropertyChangedEventArgs)
    8. If Not DesignerProperties.GetIsInDesignMode(target) Then
    9. Dim control As NotifyIcon = DirectCast(target, NotifyIcon)
    10. control.notifyIcon.Icon = FromImageSource(control.Icon)
    11. End If
    12. End Sub


    Ich habe schon ne Menge gesucht/gegooglet, aber was ist daran falsch? VS sagt:
    Für den Parameter "target" von "Private Shared Sub OnTextChanged(target As DependencyObject, e As DependencyPropertyChangedEventArgs)" wurde kein Argument angegeben

    Why? In C# gings doch auch einfach so, oder? Würde ich da eine Function ohne Signatur reinstecken, gehts von der IDE aus her...

    BTW: Wie macht man eig. den C# (C/C++) Tag?
    Mfg
    Vincent