Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8659311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:59:06+00:00 2026-06-12T15:59:06+00:00

Possible Duplicate: Method group in VB.NET? While reading an answer I got this code:

  • 0

Possible Duplicate:
Method group in VB.NET?

While reading an answer I got this code:

public static class Helper
{
    public static bool GetAutoScroll(DependencyObject obj)
    {
        return (bool)obj.GetValue(AutoScrollProperty);
    }

    public static void SetAutoScroll(DependencyObject obj, bool value)
    {
        obj.SetValue(AutoScrollProperty, value);
    }

    public static readonly DependencyProperty AutoScrollProperty =
        DependencyProperty.RegisterAttached("AutoScroll", typeof(bool),
        typeof(Helper),
        new PropertyMetadata(false, AutoScrollPropertyChanged));

    private static void AutoScrollPropertyChanged(DependencyObject d,
        DependencyPropertyChangedEventArgs e)
    {
        var scrollViewer = d as ScrollViewer;

        if (scrollViewer != null && (bool)e.NewValue)
        {
            scrollViewer.ScrollToBottom();
        }
    }
}

Since I work in VB.NET, so I converted it and got:

Public NotInheritable Class Helper

    Private Sub New()
    End Sub

    Public Shared Function GetAutoScroll(ByVal obj As DependencyObject)
    As Boolean
        Return CBool(obj.GetValue(AutoScrollProperty))
    End Function

    Public Shared Sub SetAutoScroll(ByVal obj As DependencyObject,
    ByVal value As Boolean)
        obj.SetValue(AutoScrollProperty, value)
    End Sub

    Public Shared ReadOnly AutoScrollProperty As DependencyProperty =
        DependencyProperty.RegisterAttached("AutoScroll", GetType(Boolean),
        GetType(Helper),
        New PropertyMetadata(False, AutoScrollPropertyChanged)) // Error Here

    Private Shared Sub AutoScrollPropertyChanged(ByVal d As
    System.Windows.DependencyObject, ByVal e As
    System.Windows.DependencyPropertyChangedEventArgs)
        Dim scrollViewer = TryCast(d, ScrollViewer)

        If scrollViewer IsNot Nothing AndAlso CBool(e.NewValue) Then
            scrollViewer.ScrollToBottom()
        End If
    End Sub

End Class

But the C# code compiles and works fine, but in VB.NET the code gives an error (marked in code) saying:

Argument not specified for parameter ‘e’ of ‘Private Shared Sub AutoScrollPropertyChanged(d As System.Windows.DependencyObject, e As System.Windows.DependencyPropertyChangedEventArgs)’

Eenter image description here

What am I missing? The PropertyChangedCallback delegate is exactly the way it is defined in Object Browser:

Public Delegate Sub PropertyChangedCallback(
    ByVal d As System.Windows.DependencyObject, ByVal e As
    System.Windows.DependencyPropertyChangedEventArgs)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:59:07+00:00Added an answer on June 12, 2026 at 3:59 pm

    C# has a language feature, that can convert method groups to delegate type. So, instead of:

    private void Foo() {}
    private void Bar(Action arg) {}
    
    Bar(new Action(Foo));
    

    you can write:

    Bar(Foo);
    

    I’m not a VB guy, but I suspect, that VB .NET hasn’t such feature.
    Looks like you need AddressOf operator:

    New PropertyMetadata(False, AddressOf AutoScrollPropertyChanged)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Call class instance method while debugging in eclipse Is there a way
Possible Duplicate: extension method requires class to be static Why aren't C# static class
Possible Duplicate: Calling virtual method in base class constructor Calling virtual functions inside constructors
Possible Duplicate: ASP.NET MVC3 how to excute action method of controller using timer with
Possible Duplicate: method vs function vs procedure vs class ? Can some one give
Possible Duplicate: non static method cannot be referenced from static context hey i have
Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method What's the difference between creating a prototype like
Possible Duplicate: jQuery .load method not firing on IE9 In IE7 and IE8 this
Possible Duplicate: JavaScript: Class.method vs. Class.prototype.method I am trying to understand object in JavaScript.
Possible Duplicate: HTML.ActionLink method In my ASP.NET MVC 3 application, I wish to generate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.