ArcGIS Pro Custom Icons

From: https://community.esri.com/thread/250077-custom-control-and-handling-images

Let say in xaml

<Image x:Name="ImgStatus" Grid.Column="1" Grid.Row="0" Width="32" Height="32" Source="pack://application:,,,/[your name space];component/[folder name if you put your image into the folder]/[your image name].pngVerticalAlignment="Top"></Image>

In cs file

 private void SetStatus()
        {
            this.ImgStatus.Source = this.BuildImage([Your desire image name]);
        }


/// <summary>
        /// Create bitmap image source
        /// </summary>
        /// <param name="imageName"></param>
        /// <returns></returns>
        private ImageSource BuildImage(string imageName)
        {
            return new BitmapImage(PackUriForResource(imageName));
        }
        /// <summary>
        /// Create wpf uri, make sure the image type is assembly resource
        /// </summary>
        /// <param name="resourceName"></param>
        /// <returns></returns>
        private Uri PackUriForResource(string resourceName)
        {
            string asm = System.IO.Path.GetFileNameWithoutExtension(
                System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
            return new Uri(string.Format("pack://application:,,,/{0};component/[Your image folder path]/{1}", asm, resourceName), UriKind.Absolute);
        }

 

Make sure you replace those variable with [] properly from the sample code.  and try i

Guess you like

Origin www.cnblogs.com/gisoracle/p/12622481.html