<UserControl x:Class="绑定.绑定Source" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:绑定" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Button Content="{Binding Source={x:Static local:BingdingStaticPath.BindingStaticProperty}}"></Button> </Grid> </UserControl>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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 System.ComponentModel; namespace 绑定 { /// <summary> /// 绑定Source.xaml 的交互逻辑 /// </summary> public partial class 绑定Source : UserControl { public 绑定Source() { InitializeComponent(); } } public static class BingdingStaticPath { private static string _bindingStaticProperty; public static String BindingStaticProperty { set { _bindingStaticProperty = value; } get { return _bindingStaticProperty; } } static BingdingStaticPath() { _bindingStaticProperty = "dog"; } } }
时间: 2024-10-20 17:12:00