Argument not specified for parameter

前端 未结 1 1358
夕颜
夕颜 2021-01-24 21:15

Using VB.net & WPF

I\'ve converted code available at Overlaying Controls in WPF with Adorners from C# to VB.Net

Original C# Code

            


        
相关标签:
1条回答
  • 2021-01-24 21:31

    Below code block given on blog post you are referring to has incorrect usage shown.

    using (OverlayAdorner<ProgressMessage>.Overlay(LayoutRoot)) 
    { 
       // Do some stuff here while adorner is overlaid
    }
    

    Should be (in C#):

    using (OverlayAdorner<ProgressMessage>.Overlay(LayoutRoot, this)) // Here I assume `this` is somehow `UserControl`'s object
    { 
       // Do some stuff here while adorner is overlaid
    }
    

    In VB.NET

    Using OverlayAdorner(Of UserControl).Overlay(G1, UserControl1)
       ' Do some stuff here while adorner is overlaid
    End Using
    

    Also note that: OverlayAdorner(Of UserControl1) should be OverlayAdorner(Of UserControl) because T here should be Type's name not name of object instance.

    I hope that helps.

    Some preaching

    From this question of yours I get hint that you need to work yourself on language more. Give more time to VB.NET or C#.NET and use intellisense in Visual Studio to get yourself familiar with the class library and parameter types to be passed into methods you use. This will help you working in new class libraries which have some to no documentation.

    I use this shortcut more when working in new class libaries. Type ctrl+k then ctrl+i. Generally said as ctrl+k,i

    Update

    Based on recent comment, Check the actual usage below:

    XAML snippet:

    <Window x:Class="WpfTestApp.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid x:Name="G1">
            <UserControl x:Name="ucMyControl"></UserControl>
        </Grid>
    </Window>
    

    Code behind snippet:

    Using OverlayAdorner(Of UserControl).Overlay(G1, ucMyControl)
       ' Do some stuff here while adorner is overlaid
    End Using
    
    0 讨论(0)
提交回复
热议问题