究竟这个Urikind.relative意思 [英] What exactly mean by this Urikind.relative

查看:1516
本文介绍了究竟这个Urikind.relative意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做什么是我将有一个DataGridView,当我选择一行并单击显示按钮,我想用一些信息,我写了下面的代码

What i am doing is i will have a datagridview when i select a row and click on show button i would like to display the image along with some information for that i written the following code

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);
        }
    }
}



但同样不工作如果我复制和粘贴我的图片出来斌。

But the same is not working if i copy and paste my images out of Bin.

所以,我想了解一些这方面的东西的 UriKInd

So i would like to know some thing about this UriKInd

推荐答案

相对的,而不是绝对的。 鸡/罐/ pie.jpg是相对的,因为它的相对的当前目录。而像C:/images/food/chicken/pot/pie.jpg是的绝对的,因为它是...嗯...相对的的的。驱动器

Relative, as opposed to Absolute. "chicken/pot/pie.jpg" would be relative, because it's relative to the current directory. Whereas something like "C:/images/food/chicken/pot/pie.jpg" would be absolute because it's ...err... relative to the root of the drive.

唯一真正的点初始化乌里这种方式是为了避免(或原因)异常时URI是没有很好形成;当URI是不是预先确定有用的。

The only real point to initializing the Uri this way is to avoid (or cause) exceptions when the uri is not well-formed; useful when the Uri is not predetermined.

MSDN参考

相对和绝对URI对它们的格式不同的限制。例如,一个相对URI不需要方案或权限。您在 uriKind 指定的值必须在 uriString中通过URI的类型相匹配。然而,如果指定 RelativeOrAbsolute 时,所述URI字符串可以是相对或绝对的。

Relative and absolute URIs have different restrictions on their format. For example, a relative URI does not require a scheme or an authority. The value you specify in uriKind must match the type of URI passed in uriString. However, if RelativeOrAbsolute is specified, the URI string can be relative or absolute.

这篇关于究竟这个Urikind.relative意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆