首页 > 代码库 > 数据绑定—Source(绑定到静态类的静态属性)
数据绑定—Source(绑定到静态类的静态属性)
<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"; } } }
数据绑定—Source(绑定到静态类的静态属性)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。