zoukankan      html  css  js  c++  java
  • Win10 UI入门RelativePanel

            <RelativePanel Background="Black" >
                <Rectangle  x:Name="midRe" Fill="Red" Width="100" Height="100" 
                           RelativePanel.AlignHorizontalCenterWithPanel="True"
                           RelativePanel.AlignVerticalCenterWithPanel="True"/>
                
               <Rectangle x:Name="topLeftRe" Fill="Green" Width="100" Height="100"
                          RelativePanel.AlignLeftWithPanel="True"
                          RelativePanel.AlignTopWithPanel="True"/>
    
                <Rectangle x:Name="topRightRe" Fill="Yellow" Width="100" Height="100"
                          RelativePanel.AlignRightWithPanel="True"
                          RelativePanel.AlignTopWithPanel="True"/>
    
                <Rectangle Fill="Yellow" Width="100" Height="100" RelativePanel.Above="midRe" RelativePanel.AlignLeftWith="midRe"/>
                <Rectangle Fill="Yellow" Width="100" Height="100" RelativePanel.AlignTopWith="midRe" RelativePanel.LeftOf="midRe"/>
                <Rectangle Fill="Yellow" Width="100" Height="100" RelativePanel.AlignTopWith="midRe" RelativePanel.RightOf="midRe"/>
                <Rectangle Fill="Yellow" Width="100" Height="100" RelativePanel.Below="midRe" RelativePanel.AlignLeftWith="midRe"/>

    <Rectangle Fill="Yellow" Width="50" Height="50" RelativePanel.AlignHorizontalCenterWithPanel="True"
    RelativePanel.AlignVerticalCenterWithPanel="True" RelativePanel.RightOf="midRe"
    />

                <Rectangle x:Name="bottomLeftRe" Fill="Gray" Width="100" Height="100"
                          RelativePanel.AlignLeftWithPanel="True"
                           RelativePanel.AlignBottomWithPanel="True"/>
    
                <Rectangle x:Name="bottomRightRe" Fill="Blue" Width="100" Height="100"
                          RelativePanel.AlignRightWithPanel="True"
                          RelativePanel.AlignBottomWithPanel="True"/>
            </RelativePanel>

    后代代码

    http://blog.falafel.com/windows-10-development-relativepanel/
    http://stackoverflow.com/questions/31852833/relative-width-for-ui-elements-with-relativepanel-in-xaml-with-uwp-apps

     并且可以删除子项

            /// <summary>
            /// ScrollViewer    scrollViewer = FindChildOfType<ScrollViewer>(listbox1);
            /// </summary>
            public T FindChildOfType<T>(DependencyObject root) where T : class
            {
                var queue = new Queue<DependencyObject>();
                queue.Enqueue(root);
                while (queue.Count > 0)
                {
                    DependencyObject current = queue.Dequeue();
                    for (int i = VisualTreeHelper.GetChildrenCount(current) - 1; 0 <= i; i--)
                    {
                        var child = VisualTreeHelper.GetChild(current, i);
                        var typedChild = child as T;
                        if (typedChild != null)
                        {
                            return typedChild;
                        }
                        queue.Enqueue(child);
                    }
                }
                return null;
            }
            public T FindParentOfType<T>(DependencyObject obj) where T : FrameworkElement
            {
                DependencyObject parent = VisualTreeHelper.GetParent(obj);
                while (parent != null)
                {
                    if (parent is T)
                    {
                        return (T)parent;
                    }
                    parent = VisualTreeHelper.GetParent(parent);
                }
                return null;
            }
    工具

     

  • 相关阅读:
    字节编码中文编码方式总结
    参数读取一个关于java.net.Socket的超时的问题
    属性处理器Spring攻略学习笔记(2.12)外部化Bean配置
    设置编译器让CodeBlock支持C99标准
    相机标记[置顶] OpenCV for Ios 学习笔记(6)-标记检测3
    宋体配置JAVA j2ee (一) 轻松入门
    连接固件Jlink v8固件修复
    css的使用和基本语法
    css语言基础css的选择符语法
    css语言基础css属性值的规范
  • 原文地址:https://www.cnblogs.com/luquanmingren/p/5141809.html
Copyright © 2011-2022 走看看