<DataGrid.Columns> <DataGridTextColumn Header="ID" Binding="{Binding Id, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn> <DataGridTextColumn Header="用户名" Binding="{Binding userName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn> <DataGridTextColumn Header="密码" Binding="{Binding userPwd, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></DataGridTextColumn> <DataGridComboBoxColumn Header="性别" SelectedItemBinding="{Binding userGender}" ItemsSource="{Binding Source={StaticResource ResourceKey=Gender}}"></DataGridComboBoxColumn> <DataGridHyperlinkColumn Header="邮箱" Binding="{Binding userEmail, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></DataGridHyperlinkColumn> <DataGridCheckBoxColumn Header="付账" Binding="{Binding IsPay, Mode=Default,UpdateSourceTrigger=PropertyChanged}"></DataGridCheckBoxColumn> </DataGrid.Columns>
代码如上 双击之后出现
<DataGridHyperlinkColumn Header="邮箱" Binding="{Binding userEmail, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></DataGridHyperlinkColumn>
发现删掉上面一行代码就没有错误了,应该是Hyperlink引发的的异常,本人wpf菜鸟,还请高手指教!
是不是需要把 userEmail 的类型设置为 Uri.
后台userEmail的类型是Uri
public Uri userEmail { get; set; }
如上,求解决
@yahue:
Binding="{Binding Email}" ContentBinding="{Binding Email, Converter={StaticResource EmailConverter}}"
前一个绑定值,后一个绑定显示的内容.EmailConverter 为你自己定义的将 string 转换为 uri,uri转 string的类的实例。
@程序猿.码农: 万分感谢 终于可以了