和xaml一起创建
This commit is contained in:
parent
ffa145525a
commit
c296354f7b
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="WPF基础_1_2_和xaml一起创建.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WPF基础_1_2_和xaml一起创建"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,12 @@
|
|||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace WPF基础_1_2_和xaml一起创建;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System.Windows;
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
|
@ -0,0 +1,12 @@
|
|||
<Window x:Class="WPF基础_1_2_和xaml一起创建.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:WPF基础_1_2_和xaml一起创建"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Button Name="_button">点击我</Button>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,49 @@
|
|||
using System.IO;
|
||||
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.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WPF基础_1_2_和xaml一起创建;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public MainWindow(string xamlFile)
|
||||
{
|
||||
Width = Height = 285;
|
||||
Left = Top = 100;
|
||||
Title = "混合xaml";
|
||||
|
||||
DependencyObject rootElement ;
|
||||
using (var fileStream = new FileStream(xamlFile,FileMode.Open))
|
||||
{
|
||||
rootElement = (DependencyObject)XamlReader.Load(fileStream);
|
||||
}
|
||||
|
||||
Content = rootElement;
|
||||
|
||||
_button =(Button) LogicalTreeHelper.FindLogicalNode(rootElement,"_button");
|
||||
|
||||
_button.Click += Button_OnClick;
|
||||
}
|
||||
private void Button_OnClick(object sender, RoutedEventArgs eventArgs)
|
||||
{
|
||||
_button!.Content = "栓Q";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<RootNamespace>WPF基础_1_2_和xaml一起创建</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
|
@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-1", "WPF基础-1\
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-1-1-只使用代码方式创建", "WPF基础-1-1-只使用代码方式创建\WPF基础-1-1-只使用代码方式创建.csproj", "{BD355183-DF6F-49EC-A933-0B32280BC5B6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-1-2-和xaml一起创建", "WPF基础-1-2-和xaml一起创建\WPF基础-1-2-和xaml一起创建.csproj", "{BEC5A610-FCE9-4A38-AE54-E1C516CED5E6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -24,5 +26,9 @@ Global
|
|||
{BD355183-DF6F-49EC-A933-0B32280BC5B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BD355183-DF6F-49EC-A933-0B32280BC5B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BD355183-DF6F-49EC-A933-0B32280BC5B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BEC5A610-FCE9-4A38-AE54-E1C516CED5E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BEC5A610-FCE9-4A38-AE54-E1C516CED5E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BEC5A610-FCE9-4A38-AE54-E1C516CED5E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BEC5A610-FCE9-4A38-AE54-E1C516CED5E6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
Loading…
Reference in New Issue