简体   繁体   English

为什么我的 wpf 应用程序在 web 浏览器中启动?

[英]why is my wpf application starting in web browser?

I created a wpf application which have a single window which is getting started on a web browser.我创建了一个 wpf 应用程序,它有一个 window 应用程序,它正在 web 浏览器上启动。 I need to run it as a standalone application.我需要将其作为独立应用程序运行。

Code goes below.代码如下。

<Application x:Class="WPFTESTER.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="Page1.xaml">
    <Application.Resources>

    </Application.Resources>
</Application>



<Window x:Class="WPFTESTER.MyWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid>
        <telerik:RadGridView x:Name="testGrid" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn IsReadOnly="True">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadButton Click="RadButton_Click" Content="Button1"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn IsReadOnly="True">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadButton Click="RadButton_Click" Content="Button2"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</Window>


using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls;

namespace WPFTESTER
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class MyWindow : Window
    {
        public MyWindow()
        {
            InitializeComponent();
        }

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(String.Format("{0} was clicked", (sender as RadButton).Content.ToString()));
        }
    }
}

Because you create WpfBrowserApplication .因为您创建WpfBrowserApplication Create Wpf Application and everything will be fine创建 Wpf 应用程序,一切都会好起来的

在此处输入图像描述

In the Application block you've got在您拥有的应用程序块中

StartupUri="Page1.xaml">

I'm guessing you need to change that to be the name of you main xaml page.我猜您需要将其更改为您的主 xaml 页面的名称。

Also check the project type - should not be a 'browser app'还要检查项目类型 - 不应该是“浏览器应用程序”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM