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});
            }
        }
    }
  • 相关阅读:
    HDU-2222 Keywords Search(AC自动机)
    HDU-2647 Reward(拓扑排序)
    HDU-2896 病毒侵袭(AC自动机)
    UESTC-1057 秋实大哥与花(线段树+成段加减+区间求和)
    CSU-1120 病毒(最长递增公共子序列)
    记忆化搜索
    区间动态规划 矩阵连乘 Medium
    34枚金币时间管理法
    摄影基础1
    学习法则 讲
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321064.html
Copyright © 2011-2022 走看看