zoukankan      html  css  js  c++  java
  • 【WPF】UserControl用户控件怎么添加到Window窗体中

    首先、要引用用户控件的命名控件 xmlns:my="clr-namespace:WpfApplicationDemo.Control"

    然后、把用户控件添加到窗体中

    <my:UserControl1 HorizontalAlignment="Left" Margin="38,46,0,0" x:Name="userControl11" VerticalAlignment="Top" Height="183" Width="215" />

    代码如下:

    <Window x:Class="WpfApplicationDemo.UserControlDemo"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:my="clr-namespace:WpfApplicationDemo.Control"
        Title="UserControlDemo" Height="300" Width="300" Loaded="Window_Loaded">
        <Grid>
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="textBlock1" Text="下面是用户控件" VerticalAlignment="Top" />
            <StackPanel Height="175" HorizontalAlignment="Left" Margin="20,57,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="246" />
            <my:UserControl1 HorizontalAlignment="Left" Margin="38,46,0,0" x:Name="userControl11" VerticalAlignment="Top" Height="183" Width="406" />
    
        </Grid>
    </Window>

    https://www.cnblogs.com/lelehellow/p/6026766.html

    /*******相与枕藉乎舟中,不知东方之既白*******/
  • 相关阅读:
    java日期格式转换工具类
    关于IOS给我的启发
    (转载)小米手机给我的启发和思考
    ElasticDownload
    ShopMall
    CycleViewPager
    MaterialImageView
    ZrcListView
    superCleanMaster
    QuickNewsLibs
  • 原文地址:https://www.cnblogs.com/Mars-0603/p/14745642.html
Copyright © 2011-2022 走看看