关于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 == ...
随机推荐
- Jenkins持续集成之小试牛刀
关于Jenkins的安装,大家可以参考我的这两篇文章: Ubuntu16.04环境安装jenkins docker安装jenkins及其相关问题解决 之前没有好好研究过Jenkins,只是简单学会怎么 ...
- 代码编辑器monaco-editor之基础使用
1.下载安装monaco-editor npm install monaco-editor 我的安装目录在 C://Windows//SystemApps//Microsoft.MicrosoftEd ...
- python开发技巧---列表、字典、集合值的过滤
主要学习列表,字典,集合表达式的应用: 列表的解析式: 生成一个随机列表: In [4]: datalist = [randint(-10,10) for _ in range(10)] In [5] ...
- 1002-过河卒-洛谷-luogu-动态规划dp
题目描述 棋盘上AA点有一个过河卒,需要走到目标BB点.卒行走的规则:可以向下.或者向右.同时在棋盘上CC点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点.因此称之为“马拦过河卒 ...
- 最短路径算法dijkstra的matlab实现
function Dijkstra(Graph, source): 2 3 create vertex set Q 4 5 for each vertex v in Graph: ...
- Python基础(8)——常见模块
模块介绍 time &datetime模块 random os sys shutil json & picle shelve xml处理 yaml处理 configparser has ...
- Apache与Nginx
Apache与Nginx的优缺点比较 --- 1.nginx相对于apache的优点: 轻量级,同样起web 服务,比apache占用更少的内存及资源 抗并发,nginx 处理请求是异步非阻塞的 ...
- Sql Server插入数据并返回自增ID,@@IDENTITY,SCOPE_IDENTITY和IDENT_CURRENT的区别(转载)
预备知识:SQL Server的IDENTITY关键字IDENTITY关键字代表的是一个函数,而不是identity属性.在access里边没有这个函数,所以在access不能用这个语句.语法:ide ...
- BZOJ3451 Normal 期望、点分治、NTT
BZOJCH传送门 题目大意:给出一棵树,求对其进行随机点分治的复杂度期望 可以知道一个点的贡献就是其点分树上的深度,也就是这个点在点分树上的祖先数量+1. 根据期望的线性性,考虑一个点对\((x,y ...
- (原创)odoo在docker环境下无法备份
odoo容器内置postgresql-client版本和数据库版本不一致,安装和数据库版本相同或者更高版本的客户端 参考:https://www.postgresql.org/download/lin ...