zoukankan      html  css  js  c++  java
  • WPF(x:Key 使用)

    <Window x:Class="TestOfKey.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <sys:String x:Key="myString">Hello WPF Resource!</sys:String>
        </Window.Resources>
        
        <StackPanel Background="Gray" >
            <TextBox Text="{StaticResource ResourceKey=myString}" Margin="5" />
            <TextBox x:Name="textBox1" Margin="5" />
            <Button Content="Show" Click="ButtonClick" Margin="5" />
        </StackPanel>
    </Window>
    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.Navigation;
    using System.Windows.Shapes;
    
    namespace TestOfKey
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void ButtonClick(object sender, RoutedEventArgs e)
            {
                this.textBox1.Text = this.FindResource("myString") as string;
            }
        }
    }
    


  • 相关阅读:
    Linux服务器之间进行文件目录映射/挂载 nfs rpcbind
    计算机英语Computer English
    收藏的网站
    java 通过sftp服务器上传下载删除文件
    收藏的博客
    MySQL练习题(简单查询)
    MySQL练习题
    Comparable接口和Comparator接口的使用和区别
    排序算法:快速排序
    排序算法:插入排序
  • 原文地址:https://www.cnblogs.com/wjchang/p/3671542.html
Copyright © 2011-2022 走看看