zoukankan      html  css  js  c++  java
  • 绑定元素的长宽(Canvas的子类自动伸展)

    绑定元素的大小一般会想到Width和Height但是wpf里的Width和Height如果没有显示的设置过大小那么得到的就是NaN

    要动态得到元素的大小要用ActualWidth、ActualHeight

    <UserControl x:Class="园区展示程序.MyRichTextBox"
                 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="300" d:DesignWidth="300" Name="root">
        <Canvas>
            <RichTextBox Height="{Binding ElementName=root,  Path=ActualHeight}" Width="{Binding ElementName=root,  Path=ActualWidth}" Name="content" IsReadOnly="True" Foreground="White" BorderBrush="{x:Null}" SelectionOpacity="0" BorderThickness="0"  Background="{x:Null}">
            </RichTextBox>
            <Label Height="{Binding ElementName=root,  Path=ActualHeight}" Width="{Binding ElementName=root,  Path=ActualWidth}" Opacity="0" />
        </Canvas>
    </UserControl>
  • 相关阅读:
    jquery手写实现单页滚动导航
    小程序:商品分类,实现滑块视图
    微信小程序增加悬浮在线客服
    小程序 杂记
    自动售货机 扫描支付 原理
    HTTP的SSL 证书安装
    表达
    Linux 下svn恢复到某一版本
    倒车入库 技巧
    svn 杂记
  • 原文地址:https://www.cnblogs.com/wangjixianyun/p/2982660.html
Copyright © 2011-2022 走看看