日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使silverlight适应IE窗口大小的方法

發布時間:2023/12/9 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使silverlight适应IE窗口大小的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
??? Pete Brown在它的BLOG中提到了一個按自定義比例使用silverlight適應IE窗口大小的方法

??? 原文如下:How to Resize a Silverlight 2 App and Keep the Same Aspect Ratio????????????????

??? 其核心代碼如下(
Xaml):

<UserControl?x:Class="PeteBrown.SilverlightScalingExample.Page"
????xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
????xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
????
>
???
????
<Grid?x:Name="LayoutRoot"
??????????Background
="Cornsilk"?ShowGridLines="True"
??????????Width
="400"?Height="300"
??????????RenderTransformOrigin
="0.5?0.5">
???????
????????
<Grid.RenderTransform>
????????????
<ScaleTransform?x:Name="PageScale"?ScaleX="1"?ScaleY="1"/>
????????
</Grid.RenderTransform>
???????

????
</Grid>
</UserControl>


public?partial?class?Page?:?UserControl
{
????
//?this?is?the?aspect?ratio?we?want?to?maintain
????
//?you?can?specify?this?all?sorts?of?ways,?but?the
????
//?easiest?is?to?take?the?original?size?and?divide
????
//?X?by?Y?(4:3?or?1.333?in?this?case)
????private?const?double?_originalWidth?=?400;
????
private?const?double?_originalHeight?=?300;
????
private?const?double?_originalAspectRatio?=
????????_originalWidth?
/?_originalHeight;

????
public?Page()
????{
????????InitializeComponent();

????????
//?wire?up?the?event?handler.?This?is?a?great?addition
????????
//?to?silverlight,?as?you?used?to?have?to?hook?into?the
????????
//?browser?event?yourself
????????SizeChanged?+=?new?SizeChangedEventHandler(Page_SizeChanged);
????}

????
void?Page_SizeChanged(object?sender,?SizeChangedEventArgs?e)
????{
????????
if?(e.NewSize.Width?<?_originalWidth?||
????????????e.NewSize.Height?
<?_originalHeight)
????????{
????????????
//?don't?shrink
????????????PageScale.ScaleX?=?1.0;
????????????PageScale.ScaleY?
=?1.0;
????????}
????????
else
????????{
????????????
//?resize?keeping?aspect?ratio?the?same
????????????if?(e.NewSize.Width?/?e.NewSize.Height?>?_originalAspectRatio)
????????????{
????????????????
//?height?is?our?constraining?property
????????????????PageScale.ScaleY?=?e.NewSize.Height?/?_originalHeight;
????????????????PageScale.ScaleX?
=?PageScale.ScaleY;
????????????}
????????????
else
????????????{
????????????????
//?either?width?is?our?constraining?property,?or?the?user
????????????????
//?managed?to?nail?our?aspect?ratio?perfectly.
????????????????PageScale.ScaleX?=?e.NewSize.Width?/?_originalWidth;
????????????????PageScale.ScaleY?
=?PageScale.ScaleX;
????????????}
????????}
????}
}


??? 這是一個很有用的小技巧,所以在這里做一個記號,看看將來是否能用得上:)

總結

以上是生活随笔為你收集整理的使silverlight适应IE窗口大小的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。