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
  • 相关阅读:
    stack 栈
    链表
    2018.09.08 DL24 Day1 总结
    10.07 WZZX Day2总结
    10.06 WZZX Day1总结
    Joseph问题 (线段树)
    [POI2006]TET-Tetris 3D
    10.05FZSZ Day2模拟总结
    Tarjan求LCA
    数据结构
  • 原文地址:https://www.cnblogs.com/ives/p/15567072.html
Copyright © 2011-2022 走看看