博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XAML绑定
阅读量:6820 次
发布时间:2019-06-26

本文共 3329 字,大约阅读时间需要 11 分钟。

public class Follower {   private List
skillList;   Dictionary
itemList = new Dictionary
();   public List
SkillList { get { return this.skillList; } }   public Dictionary
ItemList { get { return this.itemList; } }

如上是追随者的结构。如下绑定主手装备到XAML上

 注意的是代码中实际是ItemList["mainhand"].BorderBrush,而在XAML中,两个双引号是不能写的。

如果要绑定技能2到XAML上,如下,可以使用数字index。

 而如果要绑定collections的层级结构,则使用/即可。如下是msdn中path的解释

  • Use the Path property to specify the source value you want to bind to:
    • In the simplest case, the Path property value is the name of the property of the source object to use for the binding, such as Path=PropertyName.
    • Subproperties of a property can be specified by a syntax similar to that used in C#. For instance, the clause Path=ShoppingCart.Order sets the binding to the subproperty Order of the object or property ShoppingCart.
    • To bind to an attached property, place parentheses around the attached property. For example, to bind to the attached property DockPanel.Dock, the syntax isPath=(DockPanel.Dock).
    • Indexers of a property can be specified within square brackets following the property name where the indexer is applied. For instance, the clause Path=ShoppingCart[0] sets the binding to the index that corresponds to how your property's internal indexing handles the literal string "0". Multiple indexers are also supported.
    • Indexers and subproperties can be mixed in a Path clause; for example, Path=ShoppingCart.ShippingInfo[MailingAddress,Street].
    • Inside indexers you can have multiple indexer parameters separated by commas (,). The type of each parameter can be specified with parentheses. For example, you can have Path="[(sys:Int32)42,(sys:Int32)24]", where sys is mapped to the System namespace.
    • When the source is a collection view, the current item can be specified with a slash (/). For example, the clause Path=/ sets the binding to the current item in the view.
    • When the source is a collection, this syntax specifies the current item of the default collection view.
    • Property names and slashes can be combined to traverse properties that are collections. For example, Path=/Offices/ManagerName specifies the current item of the source collection, which contains an Offices property that is also a collection. Its current item is an object that contains a ManagerName property. Optionally, a period (.) path can be used to bind to the current source. For example, Text="{Binding}" is equivalent to Text="{Binding Path=.}".

 

补充一下,WP8开发中,app bar的icon,要求很龌龊:透明、alpha、白色前景。

我在Mspaint中画不出来,不知道怎么搞透明背景。后来搞定的方式是,vs2012中打开sdk中带的icon,把原有的select/delete掉,然后画上我自己要求的文字。 

 代码如下,出现错误,不能operated在这个stream上

 

public static BitmapImage GetBitmapFromIsolatedFolderByName(string file)        {            BitmapImage image = new BitmapImage();                        var stream = localFolder.OpenFile(cachePath+"\\"+file, System.IO.FileMode.Open);            image.SetSource(stream);            stream.Close();            return image;        }

 重点在于红色那一行,如果不close,那么第二次就会发生这个exception。令人发指的是,发生exception的时候,callstack都是reflection的东西,看不到真正的root cause。

 

 

转载地址:http://skszl.baihongyu.com/

你可能感兴趣的文章
Python爬虫的N种姿势
查看>>
MySQL小实践一:快速插入1000万条数据到MySQL数据库中
查看>>
网络协议 4 - 交换机与 VLAN
查看>>
split splice slice
查看>>
构建静态页面 之 [ 列表 ]
查看>>
函数、函数表达式、作用域、闭包
查看>>
Android 系统开发_技术细节篇 -- 快速点击导致打开两个重复的 Activity
查看>>
三十分钟成为 Contributor | 为 TiKV 添加 built-in 函数
查看>>
webpack4 系列教程: 前言
查看>>
PHP协程
查看>>
区块链技术阅读列表
查看>>
重要通知:7月31日前尽快升级您的Forge应用程序到TLS 1.2
查看>>
【刷算法】翻转单链表的递归和非递归方法
查看>>
阿里云AI如何助攻世界杯?视频集锦背后的技术实践
查看>>
ES6 系列之模拟实现 Symbol 类型
查看>>
小程序弹出菜单的实现
查看>>
领域驱动设计实战案例(六):订单上下文领域逻辑
查看>>
微信小程序开发搜索功能(前端+后端+数据库)
查看>>
装饰器模式(Decorator)
查看>>
网络(一)网络的分层
查看>>