我刚刚开始WPF.我正在startupURI从代码后面分配页面.它给了我这个错误:
找不到资源'application_startup'"
这是我在App.xaml中所做的
<Application x:Class="HelloWpf.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Application_Startup">
<Application.Resources>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
这是我在App.xaml.cs文件中所做的:
private void Application_Startup(object sender, StartupEventArgs e)
{
// Create the startup window
MainWindow wnd = new MainWindow();
// Do stuff here, e.g. to the window
wnd.Title = "Something else";
// Show the window
wnd.Show();
//Application.Current.MainWindow = wnd;
//wnd.InitializeComponent();
//wnd.Show();
}
Run Code Online (Sandbox Code Playgroud)
请帮助这个简单的代码有什么问题.谢谢
我有一个包含路径和文本的按钮.就像这样
这是我已经完成的Xaml文件
<Button Grid.Row="1" Grid.Column="0" Style="{StaticResource DashBordMenuButton}" >
<StackPanel >
<Path Name="DIcon1" Data="{StaticResource IconReporting}" Fill="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" HorizontalAlignment="Center" ></Path>
<TextBlock HorizontalAlignment="Center" Margin="0,10,0,0" > DASHBORD</TextBlock>
<TextBlock LineHeight="25" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" Margin="0,20,0,0" Text="Minir All Servers,Clients and Activies"></TextBlock>
</StackPanel>
</Button>
Run Code Online (Sandbox Code Playgroud)
样式
<Style x:Key="DashBordMenuButton" TargetType="Button">
<Setter Property="Margin" Value="10"></Setter>
<Setter Property="Background" Value="White"/>
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border" BorderThickness="1,1,1,4" BorderBrush="Gray" Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF36D8E0"/> …Run Code Online (Sandbox Code Playgroud) using System;
public class Program
{
public static void Main(string[] args)
{
#if (!pi)
Console.WriteLine("i");
#else
Console.WriteLine("PI undefined");
#endif
Console.WriteLine("ok");
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
我
还好
任何人都可以向我解释如何?如果pi没有定义,它不应该抛出异常吗?