在xaml中绑定一个类 [英] Binding a class in xaml
本文介绍了在xaml中绑定一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们,我被困了......我希望你能帮忙:)
我上课了:
< pre class ="prettyprint"> public class Result
{
public string id {get;组; }
public int time {get;组; }
public用户user {get;组; }
}
和一个可观察的集合作为listbox
ObservableCollection< Result> NotificationsLst = new ObservableCollection< Result>();
private void MainPage_Loaded(object sender,RoutedEventArgs e)
{
//将列表设置为列表框的源
lstboxNotifications.ItemsSource = NotificationsLst;
}
我有一个带有的UserControl property:
private Result NotificationResult;
public Result ContentNotification
{
get {return NotificationResult; }
设置
{
//这里我使用刚刚设置的数据..
// ...
// ... ...
// ...
}
}
并试图像这样绑定:
< telerikPrimitives:RadDataBoundListBox.ItemTemplate>
< DataTemplate>
< local:elemNotification ContentNotification =" {Binding}" />
< / DataTemplate>
< / telerikPrimitives:RadDataBoundListBox.ItemTemplate>
但这不起作用?!
它会抛出此错误:"System.ArgumentException:[Arg_ObjObjEx]"
可以有人帮忙吗?
解决方案
我相信这篇文章可能有用!
http://msdn.microsoft.com/en-us/library/ms752347 .aspx
问候,
快乐编码!
Hey guys, i'm stuck... i hope you can help :)
i've got a class:
public class Result { public string id { get; set; } public int time { get; set; } public User user { get; set; } }
and a observable collection as source for a listbox
ObservableCollection<Result> NotificationsLst = new ObservableCollection<Result>(); private void MainPage_Loaded(object sender, RoutedEventArgs e) { //Setting the list as the source for a listbox lstboxNotifications.ItemsSource = NotificationsLst; }
i've got a UserControl with a property:
private Result NotificationResult; public Result ContentNotification { get { return NotificationResult; } set { //here i work with the data that was just set.. //... //... //... } }
and trying to bind like this:
<telerikPrimitives:RadDataBoundListBox.ItemTemplate> <DataTemplate> <local:elemNotification ContentNotification="{Binding}"/> </DataTemplate> </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
but that doesn't work?!
it throws this error: "System.ArgumentException: [Arg_ObjObjEx]"
Can anybody help?
解决方案
What I believe is this that this article might work!
http://msdn.microsoft.com/en-us/library/ms752347.aspxregards,
Happy Coding!
这篇关于在xaml中绑定一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文