WP7WrapPanel

WP7WrapPanelWrapPanel:这个面板控件主要是通过Orientation属性设置包含在控件是的元素从左至右或从上至下依次安排位置,当元素超过该控件边缘时,它们将会被自动转至下一行或列。此控件一般用于文本布局、拾色器、图片等。需要加载System.Windows.Controls.Toolkit.dll WrapPanel:这个面板控件主要是通过Orientation属性设置包含在控件是的元素从

大家好,又见面了,我是你们的朋友全栈君。

WrapPanel:这个面板控件主要是通过Orientation属性设置包含在控件是的元素从左至右或从上至下依次安排位置,当元素超过该控件边缘时,它们将会被自动转至下一行或列。此控件一般用于文本布局、拾色器、图片等。需要加载System.Windows.Controls.Toolkit.dll

4adf31eat92e4abcdc844&690.jpg

 WrapPanel:这个面板控件主要是通过Orientation属性设置包含在控件是的元素从左至右或从上至下依次安排位置,当元素超过该控件边缘时,它们将会被自动转至下一行或列。此控件一般用于文本布局、拾色器、图片等。需要加载System.Windows.Controls.Toolkit.dll

Xaml代码为:
        <Grid x:Name=”ContentPanel” Grid.Row=”1″ Margin=”12,0,12,0″>
            <toolkit:WrapPanel Height=”504″ HorizontalAlignment=”Left” Margin=”9,78,0,0″ Name=”wrapPanel1″ VerticalAlignment=”Top” Width=”441″ />
            <Button Content=”清空” Height=”72″ HorizontalAlignment=”Left” Name=”button1″ VerticalAlignment=”Top” Width=”101″ Click=”button1_Click” />
            <Button Click=”OnAdd” Content=”+1″ Tag=”1″ Height=”72″ HorizontalAlignment=”Left” Margin=”107,0,0,0″ Name=”button2″ VerticalAlignment=”Top” Width=”101″ />
            <Button Click=”OnAdd” Content=”+5″ Height=”72″ HorizontalAlignment=”Left” Margin=”228,0,0,0″ Name=”button3″ Tag=”5″ VerticalAlignment=”Top” Width=”101″ />
            <Button Click=”OnAdd” Content=”+8″ Height=”72″ HorizontalAlignment=”Left” Margin=”355,0,0,0″ Name=”button4″ Tag=”8″ VerticalAlignment=”Top” Width=”101″ />
        </Grid>
CS代码为:
       Random rnd = new Random();
        private void button1_Click(object sender, RoutedEventArgs e)
        {//清空
            this.wrapPanel1.Children.Clear();
        }
        private void OnAdd(object sender, RoutedEventArgs e)
        {//根按按钮的Tag属性添加内容
            int count = Int32.Parse((string)((FrameworkElement)sender).Tag);

            while (count– > 0)
            {

                AddItem();
            }
        }

        private void AddItem()
        {//添加
            Border b = new Border()
            {

                Width = 100,
                Height = 100,
                Background = new SolidColorBrush(Color.FromArgb(255, (byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256))),
                BorderThickness = new Thickness(2),
                Margin = new Thickness(8)
            };

            b.BorderBrush = (SolidColorBrush)Resources[“PhoneForegroundBrush”];

            //b.Tap += OnTapped;

            //注册移除事件
            GestureListener listener = GestureService.GetGestureListener(b);
            listener.Tap += new EventHandler<GestureEventArgs>(WrapPanelSample_Tap);

            wrapPanel1.Children.Add(b);
        }

        void WrapPanelSample_Tap(object sender, GestureEventArgs e)
        {//移除事件
            Border b = (Border)sender;
            wrapPanel1.Children.Remove(b);
        }

        //void OnTapped(object sender, System.Windows.Input.GestureEventArgs e)
        //{

           // Border b = sender as Border;
            //if (null != b)
            //{

                //wrapPanel.Children.Remove(b);
            //}

//}
 }


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/163304.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 虚拟机安装centos7及网络配置

    虚拟机安装centos7及网络配置原文:https://blog.csdn.net/babyxue/article/details/80970526本篇文章主要介绍了VMware安装Centos7超详细过程(图文),具有一定的参考价值,感兴趣的小伙伴们可以参考一下1.软硬件准备软件:推荐使用VMwear,我用的是VMwear14镜像:CentOS7,下载地址:http://isoredirect.cen…

    2022年6月12日
    57
  • 芭比Q了,腰间盘给整突出了「建议收藏」

    在2022年除了腰间盘外,其他的各个方面都可以越来越突出!

    2022年3月1日
    151
  • VS2013 产品密钥 – 所有版本-亲试,好使!!

    VS2013 产品密钥 – 所有版本-亲试,好使!!VisualStudioUltimate2013KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9VisualStudioPremium2013KEY(密钥):FBJVC-3CMTX-D8DVP-RTQCT-92494VisualStudioProfessional2013KEY(密钥):XDM3T-W3T3V-MGJWK-8B…

    2022年5月19日
    747
  • 文件系统的类型简介「建议收藏」

    文件系统的类型简介「建议收藏」文件系统的类型简介Linux支持多种文件系统类型,包括ext2、ext3、vfat、jffs、romfs和nfs等,为了对各类文件系统进行统一管理,Linux引入了虚拟文件系统VFS(VirtualFileSystem),为各类文件系统提供一个统一的应用编程接口。根据存储设备的硬件特性、系统需求,不同的文件系统类型有不同的应用场合。在嵌入式Linux应用中,主要的存储设备为

    2022年9月15日
    3
  • C++智能指针「建议收藏」

    C++智能指针「建议收藏」一、基础知识介绍二、不带引用计数的智能指针三、带引用计数的智能指针四、shared_ptr和weak_ptr五、多线程访问共享对象的线程安全问题六、自定义删除器

    2022年6月20日
    49
  • OpenWrt make menuconfig 构建过程「建议收藏」

    OpenWrt make menuconfig 构建过程「建议收藏」OpenWrtmakemenuconfig构建过程1.课题背景之前在《20190614OpenWrt如何添加驱动以及应用程序谢艺华-遗留问题解答》文档的问题7中,承诺要写一个关于makemenuconfig的构架过程。于是就决定花点时间熟悉一下流程,方便以后的工作。2.分析过程2.1OpenWrt目录下的Makefile分析makemenuconfig的过程也…

    2022年5月12日
    45

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号