当前位置: 首页>>代码示例>>C#>>正文


C# Viewbox.SetBinding方法代码示例

本文整理汇总了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));
//.........这里部分代码省略.........
开发者ID:RiedigerD2,项目名称:OpenHouse,代码行数:101,代码来源:TreeMenu.cs


注:本文中的System.Windows.Controls.Viewbox.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。