码迷,mamicode.com
首页 > 其他好文 > 详细

数据绑定—Source(绑定到静态类的静态属性)

时间:2017-05-19 00:57:49      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:using   cti   .com   sch   str   form   属性   res   name   

<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(绑定到静态类的静态属性)

标签:using   cti   .com   sch   str   form   属性   res   name   

原文地址:http://www.cnblogs.com/dog2016/p/6876306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!