<Path Grid.Column="2" Data="M43,5 L20,40 20,40 0,20 6,15 18,26 37,7 43,5 z" Fill="Green" Margin="5"  Stretch="Fill" HorizontalAlignment="Right"/>

 <Path  Margin="5" Data="M50,25 L25,50 M25,25 50,50" Fill="#FFF4F4F5" Stretch="Fill" Stroke="Red" StrokeThickness="8" HorizontalAlignment="Right"/>

好了,看这个红叉叉打的,下面先来一条异常:

1.在“System.Windows.Baml2006.DeferredBinaryDeserializerExtension”上提供值时引发了异常

上图:

这个问题我纠结了半天查了好多资料而不可得,总以为是数据绑定之类的错误,最后才发现是一个TextBlock的背景颜色值设错了。

血淋淋的教训啊浪费了半天时间就因为自己的大意。遇到这种问题如果实在找不错问题,就一个一个剔除控件,找到出问题的控件。

2.一个自定义ListView模板,看你是否用的上

<Grid>
<ListView Name="LV_Test" SelectionMode="Multiple" Background="{x:Null}">
<ListView.Template>
<ControlTemplate>
<Border CornerRadius="10" BorderBrush="RoyalBlue" BorderThickness="5">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" >
<ItemsPresenter />
</ScrollViewer>
</Border>
</ControlTemplate>
</ListView.Template>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<Border Name="BD_Collector" CornerRadius="5" Background="DarkSeaGreen" Width="auto" Height="30" Margin="5">
<StackPanel Orientation="Horizontal">
<Label Content="{Binding XH}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="13" />
<Label Content="{Binding time}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="13" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="BD_Collector" Property="Background" Value="YellowGreen" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="BD_Collector" Property="Background" Value="DarkGreen" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="序号" DisplayMemberBinding="{Binding XH}" Width="100"/>
<GridViewColumn Header="日期" DisplayMemberBinding="{Binding time}" Width="140"/>
<GridViewColumn Header="项目" DisplayMemberBinding="{Binding CostItem}" Width="100"/>
<GridViewColumn Header="金额" DisplayMemberBinding="{Binding CostMoney}" Width="100"/>
</GridView>
</ListView.View>
</ListView>
</Grid>

上图:

未完待续……

WPF备忘录(4)打个勾画个叉娱乐下的更多相关文章

  1. WPF备忘录(3)如何从 Datagrid 中获得单元格的内容与 使用值转换器进行绑定数据的转换IValueConverter

    一.如何从 Datagrid 中获得单元格的内容 DataGrid 属于一种 ItemsControl, 因此,它有 Items 属性并且用ItemContainer 封装它的 items. 但是,W ...

  2. WPF备忘录(2)WPF获取和设置鼠标位置与progressbar的使用方法

    一.WPF 中获取和设置鼠标位置 方法一:WPF方法 Point p = Mouse.GetPosition(e.Source as FrameworkElement); Point p = (e.S ...

  3. WPF备忘录(6)WPF实现打印功能

    在WPF 中可以通过PrintDialog 类方便的实现应用程序打印功能,本文将使用一个简单实例进行演示.首先在VS中编辑一个图形(如下图所示). 将需要打印的内容放入同一个<Canvas> ...

  4. WPF备忘录(7)WPF图片资源路径介绍

    在项目中增加两张图片Content.jpg和Resource.jpg,分别将其生成操作属性设置为Content和Resource.     在界面中增加两个Image控件ImgContent和ImgR ...

  5. WPF备忘录(1)有笑脸,有Popup

    1.画个笑脸给大家娱乐一下: <Canvas Width="200" Height="180" VerticalAlignment="Cente ...

  6. WPF备忘录(5)怎样修改模板中的控件

    首先,想问大家一个问题,你们如果要给一个Button添加背景图片会怎么做?(呵呵,这个问题又点小白哈) 是这样吗? <Button Height="57" Horizonta ...

  7. WPF and Silverlight.ComboBox 如何通过 Binding IsDropDownOpen 实现下拉菜单展开

    In the WPF example the Popup and the ToggleButton (the arrow on the right) are bound with the proper ...

  8. WPF - 监听判断键盘组合键的按下

    对于键盘事件PreviewKeyDown.PreviewKeyUp.KeyDown.KeyUp,在其中检查当次事件是哪个按键触发的很简单,只需要判断KeyEventArgs类型的事件参数e的Key属性 ...

  9. C#设计模式-备忘录模式

    访问者模式的实现是把作用于某种数据结构上的操作封装到访问者中,使得操作和数据结构隔离.而本文要介绍的备忘者模式与命令模式有点相似,不同的是,命令模式保存的是发起人的具体命令(命令对应的是行为),而备忘 ...

随机推荐

  1. Delphi-idHttp-Post JSON用法 good

    从国外网站抄来的代码 Delphi source: http := TIdHttp.Create(nil);http.HandleRedirects := True;//允许头转向http.ReadT ...

  2. UvaOJ 10167

    暴力搜索 #include<cstdio> struct node { int x; int y; }s[]; int main() { //freopen("input.txt ...

  3. .net 使用HtmlAgilityPack做爬虫

    HtmlAgilityPack官网:https://html-agility-pack.net/?z=codeplex .net中使用HtmlAgilityPack做爬虫步骤: 1.在nuget中安装 ...

  4. JS中同步显示并分割输入的数字字符串

    题目比较晦涩,来张图来说明要表达的效果: 第一张图的效果就是,用户输入一个数字,上面就显示一个大层,然后显示输入的数字,并把数字用空格按照每四位分割出来.好像在建行的网上银行上面就有这种效果.第二个图 ...

  5. WPF ListBox的进阶使用(二)

    项目中经常使用需要根据搜索条件查询数据,然后用卡片来展示数据.用卡片展示数据时,界面的宽度发生变化,希望显示的卡片数量也跟随变化.WrapPanel虽然也可以实现这个功能,但是将多余的部分都留在行尾, ...

  6. 背水一战 Windows 10 (46) - 控件(ScrollViewer 基础): ScrollViewer, ScrollBar, ScrollContentPresenter

    [源码下载] 背水一战 Windows 10 (46) - 控件(ScrollViewer 基础): ScrollViewer, ScrollBar, ScrollContentPresenter 作 ...

  7. 关于WordCount的作业

    一.开发者:201631062418 二.代码地址:https://gitee.com/YsuLIyan/WordCount 三.作业地址:https://edu.cnblogs.com/campus ...

  8. vue.js - 1

    最近开发公司vue前端项目,做一下笔记,偶尔上来查漏补缺 Vue指令之v-bind的三种用法 直接使用指令v-bind 使用简化指令: 在绑定的时候,拼接绑定内容::title="btnTi ...

  9. 回车符与换行符问题——C语言

    回车符(carriage return,’\r’)与换行符 (line feed,’\n’) 从上面可以看出换行对应的ASCII码值是10,回车符对应的ASCII码值是13,需要注意的是用户按下回车键 ...

  10. Swift5 语言参考(十) 语法汇总

    词法结构 GRAMMAR OF WHITESPACE whitespace → whitespace-item whitespace opt whitespace-item → line-break ...