WPF将数字绑定到不同的数据列中
是否可以将数字绑定到其中没有数字的数据列。例如,我在数据库中将优先级存储为 1、2、3,在数据网格中我希望将其表示为 Love、Medium、High。如何将其绑定到数据列,并将其与正确的列相匹配?
<dg:DataGridComboBoxColumn Header="Priority" SelectedItemBinding="{Binding priority}" Width="SizeToCells" MinWidth="60" CanUserSort="True">
<dg:DataGridComboBoxColumn.ItemsSource>
<col:ArrayList>
<s:String>Low</s:String>
<s:String>Medium</s:String>
<s:String>High</s:String>
</col:ArrayList>
</dg:DataGridComboBoxColumn.ItemsSource>
</dg:DataGridComboBoxColumn>
Is it possible to binding a number to a datacolumn which has no number in it. For example I store the priority in the database as 1, 2, 3 and in the datagrid I want this represented as Love, Medium, High. How can I bind this to the datacolumn, and match it to the correct one?
<dg:DataGridComboBoxColumn Header="Priority" SelectedItemBinding="{Binding priority}" Width="SizeToCells" MinWidth="60" CanUserSort="True">
<dg:DataGridComboBoxColumn.ItemsSource>
<col:ArrayList>
<s:String>Low</s:String>
<s:String>Medium</s:String>
<s:String>High</s:String>
</col:ArrayList>
</dg:DataGridComboBoxColumn.ItemsSource>
</dg:DataGridComboBoxColumn>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您绑定了数字,但使用转换器将 int 转换为 Enum 值
Yes you bind the number, but use a converter to convert from int to Enum value