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});
            }
        }
    }
  • 相关阅读:
    uboot misc
    Android Q dynamic partition
    Android Verified Boot 2.0简要
    dts参考资料
    SWT问题分析总结
    lzma文件及命令简介
    C++之继承
    C++之常指针
    C++之对象成员指针
    C++之对象指针
  • 原文地址:https://www.cnblogs.com/zwzw/p/3321064.html
Copyright © 2011-2022 走看看