做网站推广有用不,嘉兴网站建设方案策划,修改网站图标,淄博品质网站建设Silverlight插件支持全屏模式#xff0c;这个没什么好说的#xff0c;只需要用设置IsFullScreen属性即可#xff0c;问题在于全屏模式中#xff0c;尽管屏幕变大了#xff0c;但是页面中的控件并未相应的变大#xff0c;下面是我在网上找到的解决这个问题的两种方式。 第… Silverlight插件支持全屏模式这个没什么好说的只需要用设置IsFullScreen属性即可问题在于全屏模式中尽管屏幕变大了但是页面中的控件并未相应的变大下面是我在网上找到的解决这个问题的两种方式。 第1种方式以图片为例即应用图片的Stretch属性 Grid x:NameLayoutRoot BackgroundWhiteImage StretchUniformToFill Source/FullScreenModel;component/Koala.jpg /Button Content全屏 Namebutton1 Clickbutton1_Click //Grid Click事件代码 private void button1_Click(object sender, RoutedEventArgs e){Application.Current.Host.Content.IsFullScreen !Application.Current.Host.Content.IsFullScreen;} 这里主要是将Image的Stretch属性设置为UniformToFill这样图片就可以根据浏览器分辨率的变化而变化这种方式在处理图片视频等资源时比较方便不过使用这种方式在插入模式下使用图片时你需要进行一些处理因为若你在Image中指定Width或Height图片在全屏模式下会保持这个固定的大小。 第2种方式则在后台进行处理当处于全屏模式时该页面上的控件也进行变化以Button为例 这种方式或许更贴近我们平常接触的全屏我们看看这部分的实现 Grid.RenderTransformScaleTransform ScaleX1 ScaleY1 x:NameRootLayoutScaleTransform/ScaleTransform/Grid.RenderTransform Button Namebutton1 Content全屏 Height30 Width50 Clickbutton1_Click Margin70,170,72,100 /Button 这里在UI中添加了一个名为RootLayoutScaleTransform的放大转换 后台代码主要是根据插件的ResizedFullScreenChanged事件进行处理的所以我们在构造函数中声明 Application.Current.Host.Content.Resized new EventHandler(Content_Resized);Application.Current.Host.Content.FullScreenChanged new EventHandler(Content_Resized); 完整的代码 private double width;private double height;public double uniformScaleAmount 1;public MainPage(){InitializeComponent();height this.Height;width this.Width;Application.Current.Host.Content.Resized new EventHandler(Content_Resized);Application.Current.Host.Content.FullScreenChanged new EventHandler(Content_Resized);}private void button1_Click(object sender, RoutedEventArgs e){Application.Current.Host.Content.IsFullScreen !Application.Current.Host.Content.IsFullScreen;}void Content_Resized(object sender, EventArgs e){double currentWidth Application.Current.Host.Content.ActualWidth;double currentHeight Application.Current.Host.Content.ActualHeight;uniformScaleAmount Math.Min((currentWidth / width), (currentHeight /height));RootLayoutScaleTransform.ScaleX uniformScaleAmount;RootLayoutScaleTransform.ScaleY uniformScaleAmount;} 页面初始化后我们先将当前插件的大小保存了下来当单击Button发生全屏事件时会进行相关事件的处理这种方式我觉得处理的更为妥善一些程序运行的时候如果你的界面上什么都没有需要设置UserControl的Width Height属性。 就看到这两种方式有更好的方法请告诉我。 代码下载FullScreenModelDemo VS2010SL3转载于:https://www.cnblogs.com/626498301/archive/2010/08/26/1808883.html