WPF绑定元素-1-示例
This commit is contained in:
parent
1805eb4bb2
commit
54c64230d8
|
@ -44,6 +44,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-16-ProgressBar",
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-17-日期控件", "WPF控件-17-日期控件\WPF控件-17-日期控件.csproj", "{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF控件-17-日期控件", "WPF控件-17-日期控件\WPF控件-17-日期控件.csproj", "{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-1-示例", "WPF绑定元素-1-示例\WPF绑定元素-1-示例.csproj", "{4AC0C9A3-D0F3-458C-AB1F-A71027447202}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -138,5 +140,9 @@ Global
|
||||||
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2F1CFE81-5AFC-4E79-A1FA-AABD7B6471D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4AC0C9A3-D0F3-458C-AB1F-A71027447202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4AC0C9A3-D0F3-458C-AB1F-A71027447202}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4AC0C9A3-D0F3-458C-AB1F-A71027447202}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4AC0C9A3-D0F3-458C-AB1F-A71027447202}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<Application x:Class="WPF元素绑定_1_示例.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_示例"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF元素绑定_1_示例;
|
||||||
|
|
||||||
|
/// <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,24 @@
|
||||||
|
<Window x:Class="WPF元素绑定_1_示例.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"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<StackPanel>
|
||||||
|
<Slider Name="SliderFontSize" Minimum="1" Maximum="100" Value="40" TickFrequency="1" TickPlacement="TopLeft" />
|
||||||
|
|
||||||
|
<Label>
|
||||||
|
Binding 绑定元素 ElementName=SliderFontSize 指定元素名称,Path=Value 指定绑定的值
|
||||||
|
</Label>
|
||||||
|
<TextBlock Margin="10" Text="简单的文字" Name="TextBlockShow"
|
||||||
|
FontSize="{Binding ElementName=SliderFontSize,Path=Value,Mode=TwoWay}" />
|
||||||
|
|
||||||
|
<WrapPanel>
|
||||||
|
<Button Margin="5 0" Padding="15 5" Name="SetSmall" Click="SetSmall_OnClick">设置小号</Button>
|
||||||
|
<Button Margin="5 0" Padding="15 5" Name="SetNormal" Click="SetNormal_OnClick">设置默认</Button>
|
||||||
|
<Button Margin="5 0" Padding="15 5" Name="SetLarge" Click="SetLarge_OnClick">设置大号</Button>
|
||||||
|
<Label>不要直接设置在字体上,会使用字面绑定代替元素绑定!!!或者使用Mode为TwoWay</Label>
|
||||||
|
</WrapPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WPF元素绑定_1_示例;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetLarge_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SliderFontSize.Value = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetNormal_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SliderFontSize.Value = 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSmall_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SliderFontSize.Value = 10;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<RootNamespace>WPF元素绑定_1_示例</RootNamespace>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue