将vb中的启动对象更改为xaml

时间:2018-09-17 05:52:42

标签: vb.net xaml ado.net

我创建了WPF应用程序 但是在更改启动对象时遇到问题,我想将其更改为xaml

在“项目属性启动对象”下拉框中,没有xaml文件。我首先取消选中启用框架,然后单击选项submain,我添加了代码,但是仍然出现错误“ wpf1中没有sub main”

Public Shared Sub Main()
        Dim app As Application = New Application()
        app.InitializeComponent()
        app.Run()
    End Sub

Namespace wpf1

    '''<summary>
    '''Application
    '''</summary>
    <Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
    Partial Public Class Application
        Inherits System.Windows.Application
        Implements System.Windows.Markup.IComponentConnector

        Private _contentLoaded As Boolean

        '''<summary>
        '''InitializeComponent
        '''</summary>
        <System.Diagnostics.DebuggerNonUserCodeAttribute(),
         System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")>
        Public Sub InitializeComponent() Implements System.Windows.Markup.IComponentConnector.InitializeComponent
            If _contentLoaded Then
                Return
            End If
            _contentLoaded = True
            Dim resourceLocater As System.Uri = New System.Uri("/wpf1;component/application.xaml", System.UriKind.Relative)

#ExternalSource ("..\..\Application.xaml", 1)
            System.Windows.Application.LoadComponent(Me, resourceLocater)

#End ExternalSource
        End Sub

        <System.Diagnostics.DebuggerNonUserCodeAttribute(),  _
         System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0"),  _
         System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never),  _
         System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes"),  _
         System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"),  _
         System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")>  _
        Sub System_Windows_Markup_IComponentConnector_Connect(ByVal connectionId As Integer, ByVal target As Object) Implements System.Windows.Markup.IComponentConnector.Connect
            Me._contentLoaded = true
        End Sub
    End Class
End Namespace

这是application.xaml

<Application x:Class="wpf1.Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:local="clr-namespace:wpf1"

    >
    <Application.Resources>

    </Application.Resources>
</Application>

和类application.vb

Class Application


    ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
    ' can be handled in this file.

    Public Shared Sub Main()
        Dim app As Application = New Application()
        app.InitializeComponent()
        app.Run(login)
    End Sub

End Class

我也试图删除startupuri,但无济于事 如何将启动对象更改为xaml?

0 个答案:

没有答案