数据绑定—Source(绑定到静态类的静态属性)
Posted 苹果园dog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数据绑定—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(绑定到静态类的静态属性)的主要内容,如果未能解决你的问题,请参考以下文章