Windows.ApplicationModel.DataTransfer.DataPackage.SetHtmlFormat C# (CSharp) Méthode

SetHtmlFormat() public méthode

public SetHtmlFormat ( [ value ) : void
value [
Résultat void
		public extern void SetHtmlFormat([In] string value);
		public extern void SetRtf([In] string value);

Usage Example

        void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            OutputText.Text = "";
            OutputResourceMapKeys.Text = "";
            OutputHtml.NavigateToString("<HTML></HTML>");

            // Set the content to DataPackage as html format
            string htmlFormat = HtmlFormatHelper.CreateHtmlFormat(this.htmlFragment);
            var dataPackage = new DataPackage();
            dataPackage.SetHtmlFormat(htmlFormat);

            // Set the content to DataPackage as (plain) text format
            string plainText = HtmlUtilities.ConvertToText(this.htmlFragment);
            dataPackage.SetText(plainText);

            // Populate resourceMap with StreamReference objects corresponding to local image files embedded in HTML
            var imgUri = new Uri(imgSrc);
            var imgRef = RandomAccessStreamReference.CreateFromUri(imgUri);
            dataPackage.ResourceMap[imgSrc] = imgRef;

            try
            {
                // Set the DataPackage to clipboard.
                Windows.ApplicationModel.DataTransfer.Clipboard.SetContent(dataPackage);
                OutputText.Text = "Text and HTML formats have been copied to clipboard. ";
            }
            catch (Exception ex)
            {
                // Copying data to Clipboard can potentially fail - for example, if another application is holding Clipboard open
                rootPage.NotifyUser("Error copying content to Clipboard: " + ex.Message + ". Try again", NotifyType.ErrorMessage);
            }
        }
All Usage Examples Of Windows.ApplicationModel.DataTransfer.DataPackage::SetHtmlFormat