格式化布尔属性的XML [英] Format XML for a boolean property

查看:82
本文介绍了格式化布尔属性的XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何格式化我的XML,这样当绑定到单选按钮时,xml字段中的值将根据需要选中或取消选中该按钮。我本来想做< accttype> 2个可能值中的1个,帐户或COD。我现在在想它应该是'Account'或null。任何提示?

 <  客户 >  
< 名称 > < /姓名 < span class =code-keyword>>
< 街道 > 115 S Charlton St < / Street >
< CityStateZip > 路易斯维尔,肯塔基州40206 < / CityStateZip >
< 电话 > 502-583-1726 < /手机 >
< 传真 > < / Fax >
< Cell > 502-471-1137 < / Cell >
< 其他 > < /其他 >
< Attn > Corey Brown < / Attn >
< span class =code-keyword>< 电子邮件 > < /电子邮件 >
< SalesPerson > < / SalesPerson >
< AcctType > 帐户< / AcctType >
< / Customer >



  <   RadioButton     x:名称  =  optAcct    IsChecked   =  {Binding AcctType}   内容  = 在帐户上    Horizo​​ntalAlignment   =      VerticalAlignment   =  Top   保证金  =  4,112,0,0   /  >  

解决方案

您可以创建模式文件(* .xsd),这样您就可以为 AccType 字段定义可能的值。

请参阅:< xsd:simpleType>元素 [ ^ ]。可以定义自定义集合。它可能是一个来源od下拉列表;)



如何使用c#在简单的xsd元素中查找限制值[ ^ ]

How would I format my XML, such that when bound to a radio button the value within the xml field would check or uncheck the button as necessary. I originally wanted to make <accttype> 1 of 2 possible values, 'Account' or 'COD'. I'm thinking now that it should either be 'Account' or null. Any tips?

<Customer>
  <Name></Name>
  <Street>115 S Charlton St</Street>
  <CityStateZip>Louisville, KY 40206</CityStateZip>
  <Phone>502-583-1726</Phone>
  <Fax></Fax>
  <Cell>502-471-1137</Cell>
  <Other></Other>
  <Attn>Corey Brown</Attn>
  <Email></Email>
  <SalesPerson></SalesPerson>
  <AcctType>Account</AcctType>
</Customer>


<RadioButton x:Name="optAcct" IsChecked="{Binding AcctType}" Content="On Account" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="4,112,0,0"/>

解决方案

You can create schema file (*.xsd), which enables you to define possible values for AccType field.
See: <xsd:simpleType> Element[^]. It's possible to define custom collection. It might be a source od dropdown list ;)

how to find restriction values in a simple xsd element with c#[^]


这篇关于格式化布尔属性的XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆