关于WrapPanel和RadioButton相互配合使用实WrapPanel现动态添加或删除项
最近在做一个项目的时候,有一个需求就是,通过RadioButton来控制一行内容的显示与不显示,当不显示的时候,下面的项能够占住相应的位置,当增加的时候,又会在原来的位置重新显示,如果使用一般的Grid或者其它的布局的时候,位置就确定下来了,但是使用WrapPanel或者StackPanel这类的控件的时候,能够在增加或者删除项的时候实现重新布局,这在实际使用的时候是非常有用的,现总结如下:
1 <WrapPanel Grid.Column="1" Grid.Row= "1" Orientation= "Vertical" HorizontalAlignment= "Center" >
2 <StackPanel Orientation= "Horizontal" Visibility= "{Binding Path=JDBHIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibility Converter}}">
3 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
4 <Label Name= "lbl00" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Width= "300"> 警单编号:</Label>
5 </Border>
6 <Border BorderBrush = "Transparent" BorderThickness= "2" Height= "70" >
7 <Label Name= "lb_id" Content= "{Binding Path=JDBH,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" Height= "66" Width= "715">
8 </Label>
9 </Border>
10 </StackPanel>
11 <StackPanel Orientation= "Horizontal" Visibility= "{Binding Path=BJSJIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}">
12 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
13 <Label Name= "lbl10" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Width= "300"> 报警时间:</Label>
14 </Border>
15 <Border BorderBrush = "Transparent" BorderThickness= "2" Height= "70" >
16 <Label Name= "lb_time" Content= "{Binding Path=BJSJ,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" VerticalAlignment= "Center" Height= "66" Width= "715" ></Label>
17 </Border>
18 </StackPanel>
19 <StackPanel Orientation= "Horizontal" Visibility= "{Binding Path=BJDZIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}">
20 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
21 <Label x:Name= "lbl20" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Margin= "0,8" Width= "300" Content= "报警地址:"/>
22 </Border>
23 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" Width= "716" >
24 <Label x:Name= "lb_addr" Content= "{Binding Path=BJDZ,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" Height= "66" Width= "715" Margin= "0,-2,-2,-2"/>
25 </Border>
26 </StackPanel>
27 <StackPanel Orientation= "Horizontal" Visibility= "{Binding Path=BJXQIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}" >
28 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
29 <Label Name= "lbl30" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Margin= "0,8" Width= "300" > 报警详情:</Label>
30 </Border>
31 <Border BorderBrush = "Transparent" BorderThickness= "2" Height= "70" Width= "716" >
32 <Label x:Name= "lb_detail" Content= "{Binding Path=BJXQ,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" Height= "66" Width= "715"/>
33 </Border>
34 </StackPanel>
35 <StackPanel Orientation= "Horizontal" Visibility= "{Binding Path=BJRIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}">
36 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
37 <Label Name= "lbl40" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Width= "300" > 报 警 人:</Label>
38 </Border>
39 <Border BorderBrush = "Transparent" BorderThickness= "2" Height= "70" Margin= "0,0,10,0" >
40 <Label Name= "lb_person" Content= "{Binding Path=BJR,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" Height= "66" Width= "715">41 42 </Label>
43 </Border>
44 </StackPanel>
45 <StackPanel Orientation = "Horizontal" Visibility= "{Binding Path=BJDHIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}" >
46 <Border BorderBrush= "Transparent" BorderThickness= "2" Height= "70" >
47 <Label Name= "lbl50" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Center" VerticalAlignment= "Center" Height= "66" Width= "300" Margin= "0,-2"> 报警电话:</Label>
48 </Border>
49 <Border BorderBrush = "Transparent" BorderThickness= "2" Height= "70" Width= "719" >
50 <Label Name= "lb_phone" Content= "{Binding Path=BJDH,Mode=TwoWay}" Style= "{StaticResource StyleLabel}" HorizontalAlignment= "Left" Height= "66" Width= "719" Margin= "-2,-2,-2,1"/>
51 </Border>
52 </StackPanel>
53 </WrapPanel>
这里在WrapPanel中嵌套多个StackPanel,注意Visibility="{Binding Path=BJDHIsVisibility, Mode=TwoWay,Converter={StaticResource BoolToVisibilityConverter}}"> 实现的核心是,这里我们定义了一个依赖项属性BJDHIsVisibility,并且和RadioButton的IsChecked属性绑定到一起,当RadioButton选中的时候,IsChecked属性为True,我们不能直接将两个属性绑定到一起,必须去定义一个转换器,将BOOL类型的值转化为Visibility所支持的形,这里需要注意,当RadioButton的IsChecked属性为False的时候,Visibility的属性为Visibility.Hidden,此时WrapPanel会实现重新排列,这是我们需要注意的地方,以后需要的时候可以参考此值!
关于WrapPanel和RadioButton相互配合使用实WrapPanel现动态添加或删除项的更多相关文章
- Xamarin.Android 入门实例(4)之实现对 SQLLite 进行添加/修改/删除/查询操作
1.Main.axml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: ...
- 利用JS实现在li中添加或删除class属性
$( function() { $("#test li").click(function(){ $("#test li").removeClass(" ...
- 动态添加试题选项按钮 radioButton(一)
最近在做WebView加载试题的功能,但是选项按钮如果放的WebView中,点击时反应很慢.于是把选项用原生的RadioButton,而试题题目和答案放在WebView中.但是选项的个数不确定,所以需 ...
- java线程同步实的现方式
为何要使用同步? java允许多线程并发控制,当多个线程同时操作一个可共享的资源变量时(如数据的增删改查), 将会导致数据不准确,相互之间产生冲突,因此加入同步锁以避免在该线程没有完成操作之前,被其他 ...
- RadioGroup动态添加RadioButton,并且获得事件
由于有许多的RadioButton是动态的,不是固定的一些,所以需要在代码中,动态的添加到RadioGroup中,下面是我的实现方法. 1.添加RadioButton到RadioGroup中 Radi ...
- QT中获取选中的radioButton的两种方法(动态取得控件的objectName之后,对名字进行比较)
QT中获取选中的radioButton的两种方法 QT中要获取radioButton组中被选中的那个按钮,可以采用两种如下两种办法进行: 方法一:采用对象名称进行获取 代码: 1 QRadioBu ...
- ThinkPHP框架下,jq实现在div中添加标签并且div的大小会随之变化
php初学者,有什么不对的还请指正. 首先是在html页面中用jq实现添加标签:divAchivePersonnal是select所在的div的外层div,divselectAchivePersonn ...
- ios 实现在tableViewCell上面添加长按手势 删除该条cell以及列表后台数据等
自己的代码 需要 把属性更改成自己要使用的 //创建长按手势 在cellForRowAtIndexPath代理方法中 UILongPressGestureRecognizer *longPres ...
- 鸡头兔头共20,脚56,鸡兔各有多少?算法实 php现版
//$x 鸡头 //$y 兔头 for ($x = 0; $x <= 20; $x++) { for ($y = 0; $y <= 20; $y++) { if (($x + $y == ...
随机推荐
- 使用js切割URL的参数
对于一些开发场景,不使用Jsp或freemarker及其其他的模板引擎时,通常通过切割url获得对应的参数,然后通过AJAX与后台交互得到对应的数据 下面是演示实例: test.html <!D ...
- Omi框架学习之旅 - 组件通讯(data-*通讯) 及原理说明
上一篇文章说了omi中的组件,以及组件如何使用及嵌套. 那omi中的组件是怎么通讯的呢? 其实omi提供的通讯方式比较丰富,各有千秋,各有各的场景用途.所以按需使用即可. 老规矩:先上demo代码, ...
- 随笔一个dom节点绑定事件
以下利用jquery说明: js中,给一个dom节点绑定事件再平常不过了.这里说下,如果dom经常发生变化的话,给这个dom绑定事件的情况. 比如代码如下: li的节点,绑定了事件:点击会打出来里头的 ...
- linux中yum与rpm区别
一.源代码形式 1. 绝大多数开源软件都是直接以原码形式发布的 2. 源代码一般会被打成.tar.gz的归档压缩文件 3. 源代码需要编译成为二进制形式之后才能够运行使用 ...
- 复习整理9:SpringMVC应用以及源码解析
一:SpringMVC是什么 SpringMVC只是Spring的一个子框架,作用学过Struts2的应该很好理解,他们都是MVC的框架.学他就是用来代替Struts2的,那么为什么不用Struts2 ...
- CF487E Tourists 圆方树、树链剖分
传送门 注意到我们需要求的是两点之间所有简单路径中最小值的最小值,那么对于一个点双联通分量来说,如果要经过它,则一定会经过这个点双联通分量里权值最小的点 注意:这里不能缩边双联通分量,样例\(2\)就 ...
- C#的delegate简单练习
delegate中文的意思为委托. 在很久之前,Insus.NET有写过一篇<用一个简单的例子来演绎事件委托>http://www.cnblogs.com/insus/p/3732075. ...
- Linux/CentOS下安装MySql RPM Bundle
一.下载对应的版本的MySql安装文件 1.下载路径 https://dev.mysql.com/downloads/mysql/ 2.选择对应的Linux版本和x86/x64位的安装文件 查看Lin ...
- UML类图应该怎么看?
学无止境,精益求精 十年河东,十年河西,莫欺少年穷 学历代表你的过去,能力代表你的现在,学习代表你的将来 我每次写博基本都是这样开头,除了激励自己,每句话也都挺有道理! 呵呵,今天是阴历2017年我工 ...
- CF [2016-2017 ACM-ICPC CHINA-Final][GYM 101194 H] Great Cells
很久以前做的一道思博题了,今天来补一补. 大致题意:在一个\(n*m\)的矩阵内填整数,数字在\([1,k]\)范围内.矩阵中某格的数为great number当且仅当与它同行同列的数字都严格比它小. ...