哎呀,虽然我一直在谷歌搜索,我真的很感激,如果有人可以打破我的问题,因为在线的所有代码示例让我困惑,而不是协助(也许它只是迟到)...
我有一个简单的类定义如下:
public class Person
{
int _id;
string _name;
public Person()
{ }
public int ID
{
get { return _id; }
set { _id = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
存储在数据库中,并通过一些代码我将它放入一个ObservableCollection对象,以便稍后尝试在WPF中进行数据绑定:
public class People : ObservableCollection<Person>
{
public People() : base() { }
public void Add(List<Person> pListOfPeople)
{
foreach (Person p in pListOfPeople) this.Add(p);
}
}
Run Code Online (Sandbox Code Playgroud)
在XAML中,我自己有一个ListView,我希望为"People"对象中的每个项目填充ListViewItem(由文本块组成),因为它从数据库中更新.我还希望该文本块绑定到Person对象的"Name"属性.
我一开始以为我能做到这一点:
lstPeople.DataContext = objPeople;
Run Code Online (Sandbox Code Playgroud)
其中lstPeople是我的XAML中的ListView控件,但那当然什么也没做.我在网上找到了大量的例子,人们通过XAML创建了一个对象,然后通过他们的XAML绑定到它; 但不是我们绑定到实例化对象并相应地重新绘制的对象. …
我偶然发现了这个youtube视频http://www.youtube.com/watch?v=Ha5LficiSJM,它演示了使用AForge.NET框架进行颜色检测的人.我想复制作者所做的但我不知道如何进行一些图像处理.
似乎AForge.NET框架允许您从Bitmap格式的视频源下拉图像.我的问题是,有人能指出我的方向或提供一些指导如何询问Bitmap对象,以找到其中的特定颜色?(例如 - 如果图像中有"红色"或"紫色"持续X秒,我想提出一个事件'ColorDetected'左右......)
有没有人对从哪里开始有任何建议?
谢谢,
-R.
编辑:我是否需要遍历整个Bitmap对象并询问每个像素的颜色?像这样:http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.getpixel.aspx
我意识到这个问题可以归结为"我的代码为什么这么慢?" 但我希望能从中得到更多.让我解释一下我的代码.
我有一个实现INotifyPropertyChanged的类来进行绑定,该类看起来类似于:
public class Employee : INotifyPropertyChanged
{
string m_strName = "";
string m_strPicturePath = "";
public event PropertyChangedEventHandler PropertyChanged;
public string Picture
{
get { return this.m_strPicturePath; }
set { this.m_strPicturePath = value;
NotifyPropertyChanged("Picture"); }
}
public string Name
{
get { return this.m_strName; }
set { this.m_strName = value;
NotifyPropertyChanged("Name");
}
}
private void NotifyPropertyChanged(String pPropName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(pPropName));
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的XAML中,我创建了一个绑定到该对象的DataTemplate:
<DataTemplate x:Key="EmployeeTemplate">
<Border Height="45" CornerRadius="0" BorderBrush="Gray" BorderThickness="0" Background="Transparent" …Run Code Online (Sandbox Code Playgroud)