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});
            }
        }
    }
  • 相关阅读:
    图的连通性问题之tarjan算法
    图的连通性问题之强连通分量初步
    NOIP 2010 引水入城
    最短路经典例题 codevs 1557 热浪
    图的连通性问题之连通和最小环
    最短路径算法
    《数据结构与算法-Javascript描述》
    蓝天白云
    《慢慢来,一切都还来得及》
    聚餐
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321064.html
Copyright © 2011-2022 走看看