在WPF用户控件DesignWidth和宽度之间的区别 [英] Difference between DesignWidth and Width in UserControl in WPF

查看:5322
本文介绍了在WPF用户控件DesignWidth和宽度之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个新的用户控件在WPF,工作室创建一些XAML:

When I create a new UserControl in WPF, studio creates some XAML:

<UserControl x:Class="MOG.Objects.Date.Calender"
             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">

    <Grid>

    </Grid>
</UserControl>

UserContol 我还可以添加Width属性。之间有什么区别 DesignWidth 宽度

In UserContol I can also add Width property. What is difference between DesignWidth and Width?

推荐答案

属性 D:DesignHeight D:DesignWidth =300的使用,因为( 来源 ):

Properties d:DesignHeight and d:DesignWidth="300" are used because (Source):


  • 用户控件未嵌入在一个父视图。 宽度高度未设置。

根元素的构造不叫。根元素是由设计者所取代。未创建视图​​模型。

Constructor of the root-element is not called. Root Element is replaced by the designer. ViewModel is not created.

控件的行为不同。没有鼠标和键盘事件。
款延期加载

Controls behave different. No mouse and keyboard events. Design time extensions loaded

要提高设计经验,微软提供了可以添加特殊designtime属性。任何WPF元素,并作为设计工具的提示

To improve the design experience, Microsoft provides special designtime attributes that can be added to any WPF element and serve as a hint for the design tool.

所有这些前缀使用D:用于设计模式,其中包括诸如属性:

All that is used in the prefix d: is used to design mode, these include properties such as:

D:DesignWidth

D:DesignHeight

D:LayoutOverrides

这篇关于在WPF用户控件DesignWidth和宽度之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆