zoukankan      html  css  js  c++  java
  • wpf usercontrol封装公共基类

    1. 创建普通类而不是usercontrl,然后继承usercontrol
    public abstract class PureBaseUserControl : UserControl
    {
    
    }
    
    1. 修改子类的usercontrol继承上面的基类(需要改两处)
      将子类的前台代码最外侧的改为上面的基类(注意下方的wpfinherit:PureBaseUserControl)
    <wpfinherit:PureBaseUserControl  xmlns:wpfinherit="clr-namespace:WPFInherit" x:Class="WPFInherit.TestControl"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 mc:Ignorable="d" 
                 d:DesignHeight="450" d:DesignWidth="800">
        <Grid>
            <TextBlock x:Name="txtShow"/>
        </Grid>
    </wpfinherit:PureBaseUserControl>
    

    再调整子类的后台代码继承基类

    public partial class TestControl : PureBaseUserControl
    {
    
    }
    
    留待后查,同时方便他人
    联系我:renhanlinbsl@163.com
  • 相关阅读:
    Transformation
    Yet Another Number Sequence
    Table
    K个联通块
    Acyclic Organic Compounds
    Sandy and Nuts
    tetrahedron
    BZOJ4750 密码安全
    实现商品秒杀 时间倒计时
    实现qq登录
  • 原文地址:https://www.cnblogs.com/ives/p/15567072.html
Copyright © 2011-2022 走看看