本文整理汇总了C#中System.Windows.Controls.Viewbox.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Viewbox.SetBinding方法的具体用法?C# Viewbox.SetBinding怎么用?C# Viewbox.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Viewbox
的用法示例。
在下文中一共展示了Viewbox.SetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillDrawing
/// <summary>
/// Once the children have been set up useing makeTree
/// fills the Menus canvas with buttons to correspond to the sizes of the Squares
/// </summary>
private void FillDrawing()
{
if (canvas == null)
{
canvas = new Canvas();
}
foreach (Square block in children)
{
if (children.Count() == 1)
{
if (block.VideoString != null && !block.VideoString.Equals(""))
{
SurfaceButton button = new SurfaceButton();
SetButton(button, block);
System.Windows.Data.Binding bind = new System.Windows.Data.Binding("Width");
bind.Source = button;
bind.Converter = new BindReducer();
TextBlock txt = block.GetTextBlockLeft();
txt.FontSize = 12;
txt.SetBinding(TextBlock.WidthProperty, bind);
StackPanel panel = new StackPanel();
panel.Children.Add(txt);
VideoPlayer player = new VideoPlayer(block.VideoString);
Viewbox vb = new Viewbox();
System.Windows.Data.Binding vbBind = new System.Windows.Data.Binding("ActualHeight");
vbBind.Source = txt;
vbBind.Converter = new HeightConverter();
vbBind.ConverterParameter = this;
vb.Child = player;
vb.SetBinding(Viewbox.HeightProperty, vbBind);
panel.Children.Add(vb);
FindRightFontSize(txt, block);
button.Content = panel;
canvas.Children.Add(button);
}
else if (block.singleImage != null)
{
if (block.singleImage.Placement != _Placement.Inline)
{
SurfaceButton button = new SurfaceButton();
SetButton(button, block);
System.Windows.Data.Binding bind = new System.Windows.Data.Binding("Width");
bind.Source = button;
bind.Converter = new BindReducer();
TextBlock txt = block.GetTextBlockLeft();
txt.SetBinding(TextBlock.WidthProperty, bind);
StackPanel panel = new StackPanel();
Image img = new Image();
img.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
img.Stretch = Stretch.UniformToFill;
img.Source = new BitmapImage(new Uri(block.singleImage.Path, UriKind.Relative));
Viewbox vb = new Viewbox();
System.Windows.Data.Binding vbBind = new System.Windows.Data.Binding("ActualHeight");
vbBind.Source = txt;
vbBind.Converter = new HeightConverter();
vbBind.ConverterParameter = this;
vb.Child = img;
vb.SetBinding(Viewbox.HeightProperty, vbBind);
if (block.singleImage.Placement == _Placement.Bottom)
{
panel.Children.Add(txt);
panel.Children.Add(vb);
}
else
{
panel.Children.Add(vb);
panel.Children.Add(txt);
}
button.Content = panel;
FindRightFontSize(txt, block);
canvas.Children.Add(button);
}
else//inline
{
TextBlock visibleblock = block.GetTextBlockTop();
visibleblock.Measure(new Size(0, 0));
visibleblock.Arrange(new Rect(0, 0, 0, 0));
//.........这里部分代码省略.........