how to get the correct uri for image in code behind

2 posts, 0 answers
  1. Zi
    Zi avatar
    13 posts
    Member since:
    Jun 2013

    Posted 06 Jul 2013 Link to this post

    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.
     
            
  2. Anna
    Admin
    Anna avatar
    99 posts

    Posted 10 Jul 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top