zoukankan      html  css  js  c++  java
  • WPF 绑定五(本身就是数据源)

    xaml:

    <Window x:Class="WpfApplication1.Window5"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:String="clr-namespace:System;assembly=mscorlib"
            Title="Window5" Height="331" Width="538">
        <StackPanel Height="184" Name="stackPanel1" Width="288">
            <StackPanel.Resources>
                <String:String x:Key="myString">
                    Hello,Good Afternoon!
                </String:String>
                
            </StackPanel.Resources>
            <TextBlock Height="23" Name="textBlock1" Text="{Binding Path=.,Source={StaticResource ResourceKey=myString}}" />
        </StackPanel>
    </Window>

    cs:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    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.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// Window5.xaml 的交互逻辑
        /// </summary>
        public partial class Window5 : Window
        {
            public Window5()
            {
                InitializeComponent();
                string myString = "Hello,Good Afternoon!";
                this.textBlock1.SetBinding(TextBlock.TextProperty, new Binding(".") { Source=myString});
            }
        }
    }
  • 相关阅读:
    centos7安装pycharm
    centos7 mysql数据库安装
    删除MySQL服务
    计组第三章预习
    攻防世界web新手练习区
    原码补码预习
    第一次总结
    第三章预习
    数据结构十进制数表示
    预习原码补码
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321064.html
Copyright © 2011-2022 走看看