This is a migrated thread and some comments may be shown as answers.

how to get the correct uri for image in code behind

1 Answer 690 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Zi
Top achievements
Rank 1
Zi asked on 06 Jul 2013, 07:46 PM
hi, I've new to telerik for WPF. Now i am going to develop a multi-touch campus map for guiding.
My code for the image as follows, but error is"Could not find a part of the path 'D:\campus_floorplan;component\images\directory_level1.png'."
Code:
private void get(int i)
        {
            
           
                ImageBrush b = new ImageBrush();

                switch (i)
                {
                   

                    case 1:
                        {
                            b.ImageSource = new BitmapImage(new Uri("/campus_floorplan;component/images/directory_level1.png", UriKind.Relative));
                            b.Stretch = Stretch.Uniform;
                            this.Background = b;
                        };
                        break;
                    case 2:
                        {
                            b.ImageSource = new BitmapImage(new Uri("/campus_floorplan;component/images/directory_level2.png", UriKind.Relative));
                            b.Stretch = Stretch.Fill;
                            this.Background = b;
                        };
                        break;
                    case 3:
                        {
                            b.ImageSource = new BitmapImage(new Uri("/campus_floorplan;component/images/directory_level3.png", UriKind.Relative));
                            b.Stretch = Stretch.Fill;
                            this.Background = b;
                        };
                        break;
                    case 4:
                        {
                            b.ImageSource = new BitmapImage(new Uri("/campus_floorplan;component/images/directory_level4.png", UriKind.Relative));
                            b.Stretch = Stretch.Fill;
                            this.Background = b;

                        };
                        break;
}
            }
 private void level1_touchdown(object sender, TouchEventArgs e)
        {
            radMap.Visibility = Visibility.Collapsed;
            this.get(1);

        }
  So how to get the correct path for image??
Hope you can help me.
Thank you very much.
 
        

1 Answer, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 10 Jul 2013, 09:29 AM
Hi,

It seems that there is a mistake in the path of the Uri that you are trying to initialize but it is hard to tell where precisely the problem might be by looking just at the code itself. I believe you might find a way to solve the problem in this article.

I hope this link will be helpful. If you happen to stumble onto an issue with the Telerik controls, please, do not hesitate to get in touch with us again.

Regards,
Anna
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ImageEditor
Asked by
Zi
Top achievements
Rank 1
Answers by
Anna
Telerik team
Share this question
or