我正在做的是,当我选择一行并点击显示按钮时,我将拥有一个datagridview,并希望显示该行的图像以及一些信息。为此,我编写了以下代码:
public partial class WpfWindow : Window
{
private UCPersons _ucPersons;
public WpfWindow()
{
InitializeComponent();
// Create WinForms Usercontrol and
// add it to the WindowsFormsHost
_ucPersons = new UCPersons();
winFormHost.Child = _ucPersons;
List<Person> persons = CreateSamplePersons();
_ucPersons.SetData(persons);
}
private List<Person> CreateSamplePersons()
{
List<Person> persons = new List<Person>();
persons.Add(Person.Create("Dorababu", "Madhuranagar", "Hyd",
DateTime.Now.AddYears(-34), "1"));
persons.Add(Person.Create("Krish", "Sat", "RJY",
DateTime.Now.AddYears(-64), "2"));
return persons;
}
private void btnDisplayDetails_Click(object sender, RoutedEventArgs e)
{
Person person = _ucPersons.GetSelectedPerson();
if (person != null)
{
lblName.Content = person.Name;
lblAge.Content = person.BirthDay.ToShortDateString();
Uri uri = new Uri( "m_" + person.ImageRef + ".jpg",
UriKind.Relative);
imgPerson.Source = BitmapFrame.Create(uri);
}
}
}
如果我将图像从Bin中复制并粘贴到其他地方,它就不能正常工作。
因此,我想了解一些关于UriKInd的知识。