网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Silverlight中ViewBox组件如何使用

这期内容当中小编将会给大家带来有关Silverlight中ViewBox组件如何使用,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

我们提供的服务有:网站建设、做网站、微信公众号开发、网站优化、网站认证、洋县ssl等。为超过千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的洋县网站制作公司

组件所在命名空间:

System.Windows.Controls

组件常用属性:

Child:获取或设置一个ViewBox元素的单一子元素。

Stretch:获取或设置拉伸模式以决定该组件中的内容以怎样的形式填充该组件的已有空间。

StretchDirection:获取或设置该组件的拉伸方向以决定该组件中的内容将以何种形式被延展。

实例:

详细的说明在代码注释中给出。

MainPage.xaml文件代码:

                 

MainPage.xaml.cs文件代码:

using System;  using System.Collections.Generic;  using System.Linq;  using System.Net;  using System.Windows;  using System.Windows.Controls;  using System.Windows.Documents;  using System.Windows.Input;  using System.Windows.Media;  using System.Windows.Media.Animation;  using System.Windows.Shapes;  namespace SilverlightClient  {  //辅助类StretchHelper  public class StretchHelper  {  public string StretchModeName { get; set; }  public Stretch theStretchMode { get; set; }  }  //辅助类StretchDirectionHelper  public class StretchDirectionHelper  {  public string StretchDirectionName { get; set; }  public StretchDirection theStretchDirection { get; set; }  }  public partial class MainPage : UserControl  {  //定义cbStretch与cbStretchDirection的数据源  List cbStretchList = new List();  List cbStretchDirectionList = new List();  public MainPage()  {  InitializeComponent();  //注册事件触发  this.Loaded += new RoutedEventHandler(MainPage_Loaded);  this.cbStretch.SelectionChanged += new SelectionChangedEventHandler(cbStretch_SelectionChanged);  this.cbStretchDirection.SelectionChanged += new SelectionChangedEventHandler(cbStretchDirection_SelectionChanged);  this.HSlider.ValueChanged += new RoutedPropertyChangedEventHandler(HSlider_ValueChanged);  this.VSlider.ValueChanged += new RoutedPropertyChangedEventHandler(VSlider_ValueChanged);  }  void VSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)  {  sampleViewBox.Height = theContainer.ActualHeight * VSlider.Value / 100.0;  }  void HSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)  {  sampleViewBox.Width = theContainer.ActualWidth * HSlider.Value / 100.0;  }  void cbStretchDirection_SelectionChanged(object sender, SelectionChangedEventArgs e)  {  if (cbStretchDirection.SelectedItem != null)  {  sampleViewBox.StretchDirection = (cbStretchDirection.SelectedItem as StretchDirectionHelper).theStretchDirection;  }  }  void cbStretch_SelectionChanged(object sender, SelectionChangedEventArgs e)  {  if (cbStretch.SelectedItem != null)  {  sampleViewBox.Stretch = (cbStretch.SelectedItem as StretchHelper).theStretchMode;  }  }  void MainPage_Loaded(object sender, RoutedEventArgs e)  {  //填充各ComboBox内容  cbStretchList.Add(new StretchHelper() { StretchModeName = "Fill", theStretchMode = Stretch.Fill });  cbStretchList.Add(new StretchHelper() { StretchModeName = "None", theStretchMode = Stretch.None });  cbStretchList.Add(new StretchHelper() { StretchModeName = "Uniform", theStretchMode = Stretch.Uniform });  cbStretchList.Add(new StretchHelper() { StretchModeName = "UniformToFill", theStretchMode = Stretch.UniformToFill });  cbStretch.ItemsSource = cbStretchList;  cbStretch.DisplayMemberPath = "StretchModeName";  cbStretchDirectionList.Add(new StretchDirectionHelper() { StretchDirectionName = "DownOnly", theStretchDirection = StretchDirection.DownOnly });  cbStretchDirectionList.Add(new StretchDirectionHelper() { StretchDirectionName = "UpOnly", theStretchDirection = StretchDirection.UpOnly });  cbStretchDirectionList.Add(new StretchDirectionHelper() { StretchDirectionName = "Both", theStretchDirection = StretchDirection.Both });  cbStretchDirection.ItemsSource = cbStretchDirectionList;  cbStretchDirection.DisplayMemberPath = "StretchDirectionName";  }  }  }

最终效果图:

Silverlight中ViewBox组件如何使用 

上述就是小编为大家分享的Silverlight中ViewBox组件如何使用了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注创新互联行业资讯频道。


网页题目:Silverlight中ViewBox组件如何使用
文章URL:http://bjjierui.cn/article/gdcgio.html

其他资讯