One of the new features in 3.5 SP1 is stringformat. The usage is pretty simple. So following are simple snippets showing its use
<TextBox Text="{Binding Path=Double,StringFormat=F3}"/><TextBox Text="{Binding Path=Double,StringFormat=Amount: {0:C}}"/><TextBox Text="{Binding Path=Double,StringFormat=Amount: \{0:C\}}"/><TextBox> <TextBox.Text> <Binding Path="Double" StringFormat="{}{0:C}"/> </TextBox.Text></TextBox>
<TextBox> <TextBox.Text> <MultiBinding StringFormat="{}{0:F2} = {1:D}"> <Binding Path="Double" /> <Binding Path="Date"/> </MultiBinding> </TextBox.Text></TextBox><TextBox> <TextBox.Text> <Binding Path="Date" StringFormat="{}{0:MM/dd/yyyy}"/> </TextBox.Text></TextBox>
<ListBox Background="Beige" ItemStringFormat="F3"> <sys:Double>1.11122</sys:Double> <sys:Double>2.11345</sys:Double></ListBox> <GroupBox Background="AliceBlue" Content="{Binding Path=Double}" ContentStringFormat="F4" header="{Binding Path=Double}" headerStringFormat="F5"/><Label Content="{Binding Path=Double}" ContentStringFormat="{}{0:E2}"/><GrIDVIEw> <GrIDVIEwColumn header="Date" displayMemberBinding="{Binding XPath=Date,StringFormat=D}" /><sdk:DataGrID name="dgtable" autoGenerateColumns="False" > <sdk:DataGrID.Columns> <sdk:DataGrIDTextColumn header="时间" Binding="{Binding createdate,StringFormat=yyyy-MM-dd}" /> <sdk:DataGrIDTextColumn header="时间1" > <sdk:DataGrIDTextColumn.Binding> <Binding Path="createdate" StringFormat="{}{0:MM/dd/yyyy}"/> </sdk:DataGrIDTextColumn.Binding> </sdk:DataGrIDTextColumn> <sdk:DataGrIDTextColumn header="时间2" Binding="{Binding createdate,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" />
总结
以上是内存溢出为你收集整理的Silverlight/wpf DataGrid TextBox 等控件内容 Binding 中日期格式 StringFormat全部内容,希望文章能够帮你解决Silverlight/wpf DataGrid TextBox 等控件内容 Binding 中日期格式 StringFormat所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)