<Window x:Class="Wpf180706.Window10"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window10" Height="300" Width="300">
    <Window.Resources>
        <ControlTemplate x:Key="temp">
            <StackPanel Background="Yellow">
                <TextBox Name="txt1" Margin="6"></TextBox>
                <TextBox Name="txt2" Margin="6"></TextBox>
                <TextBox Name="txt3" Margin="6"></TextBox>
            </StackPanel>
            
        </ControlTemplate>
    </Window.Resources>
    
    <Grid>
        <StackPanel>
            <UserControl Name="uc" Template="{StaticResource temp}"></UserControl>
            <Button Click="btn_Click">btn</Button>
        </StackPanel>
    </Grid>

</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 Wpf180706
{
    /// <summary>
    /// Interaction logic for Window10.xaml
    /// </summary>
    public partial class Window10 : Window
    {
        public Window10()
        {
            InitializeComponent();
        }

        private void btn_Click(object sender, RoutedEventArgs e)
        {
            TextBox txt = (TextBox)this.uc.Template.FindName("txt1",this.uc);
            txt.Text = "Hello";
            StackPanel sp = txt.Parent as StackPanel;
            ((TextBox)sp.Children[1]).Text = "Hello2";
            ((TextBox)sp.Children[2]).Text = "Hello3";
        }
    }
}

最新文章

  1. Creating Signing Identities 生成签名标识
  2. 终端 git log 修改样式
  3. 【项目】iOS - 使用UIWebView占用内存过大
  4. HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)
  5. Jackson - Date Handling
  6. UVA 11916 Emoogle Grid 离散对数 大步小步算法
  7. 数据库(学习整理)----4--Oracle数据查询(基础点1)
  8. Android Fragment 嵌套使用报错
  9. 项目管理实践【五】自动编译和发布网站【Using Visual Studio with Source Control System to build and publish website automatically】
  10. 原生js 实现 Ajax 跨浏览器使用
  11. css雪碧图(css splite)
  12. TurnipBit—MicroPython开发板:从积木式编程语言开始学做小小创客
  13. [个人项目] echarts 实现数据(tooltip)自动轮播插件
  14. SpringMVC系列(五)使用 Serlvet 原生的 API 作为目标方法的参数
  15. eclipse maven jetty启动修改默认端口
  16. DWG/DGN格式导入Arcgis;转化为shp格式;更改地理坐标;导入Google Earth【转】
  17. Let Her Go
  18. 20145302张薇《Java程序设计》第五周学习总结
  19. 一款连接SqlServer的数据库工具
  20. hdu 3835:R(N)(水题,数学题)

热门文章

  1. .net下载优酷1080P视频
  2. HPE Comware Lab - Simulator
  3. pycharm的集成vim
  4. 【9107】Hanoi双塔问题(NOIP2007)
  5. html5-3 html5标签(热点地图如何实现)(边学边做)
  6. Redis的增删改查、持久化你会了吗
  7. node转发formdata
  8. thinkphp5开发规范(加强复习之前的)
  9. PatentTips - Heterogeneous Parallel Primitives Programming Model
  10. 递归(c++)(转)