silverlight中的几个冷门标记 {x:Null},d:DesignWidth,d:DesignHeight

{x:Null}:用于设置某属性值为Null,比如<Rectangle Fill="{x:Null}" />,其实就相当于<Rectangle />,个人感觉这个纯属MS的多余设计

另外要注意一个问题:


<Rectangle x:Name="rect" Stroke="Black" Width="90" Height="90" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp" StrokeThickness="10" />


运行时,如果点击矩形中间区域,会发现无法触发Rectangle_MouseLeftButtonUp事件,因为矩形Fill属性为null,没有填充,相当于透明,所以鼠标点击穿透矩形,点到下面的东西上去了

解决办法:设置Fill="#00000000" 即设置一个完全透明的颜色


d:DesignWidth=640,d:DesignHeight=480,这二个标记在blend中特别有用


<UserControl x:Class="MsShowCase.NavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="640"
Width="480">


默认情况下,silverlight总会有一个固定的尺寸,要想让其自动扩展,很简单把Height="640",Width="480"删除即可(或设置成Auto),但是这样处理后,用blend再打开该xaml文件,可视区域就为0了,很不方便选取对象,这时我们可以加上这二个标识,



<UserControl x:Class="MsShowCase.NavItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Height="Auto"
Width="Auto"
d:DesignWidth=640
d:DesignHeight=480
>

再用blend打开时,会发现可视区域变成640*480了,而运行时即仍然可以自动扩展
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值