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

[Solved] share chart on windows 8 app XAML

4 Answers 83 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Thanaphon
Top achievements
Rank 1
Thanaphon asked on 05 Mar 2013, 09:46 AM
How to code "share chart on windows 8 app XAML"

4 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 05 Mar 2013, 05:27 PM
Hello Thanaphon,

Thank you for your interest.

I assume that by "share chart" you mean RadPieChart. You can check the sample setup of RadPieChart in our online documentation here - http://www.telerik.com/help/windows-8-xaml/radchart-series-pieseries.html.

I hope this is useful. Let me know if you need further assistance.

 

Greetings,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Thanaphon
Top achievements
Rank 1
answered on 06 Mar 2013, 03:00 AM
Yes, my mean is RadPieChart. but I am want to share my chart to my friend by email or facebook as windows 8 feature.
0
Ivaylo Gergov
Telerik team
answered on 07 Mar 2013, 04:06 PM
Hi Thanaphon,

This functionality is related entirely with the WinRT platform so you can check in the MSDN library how they suggest to handle such situations - http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh871373(v=win.10).aspx.
Note, that at this point the platform does not provide any means to take a picture of already existing visual element in XAML.

I hope this information is useful.

 

Kind regards,
Ivaylo Gergov
the Telerik team
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
Abdu
Top achievements
Rank 1
answered on 05 Jun 2014, 11:13 AM
Hi,

We can share the chart via screen shot, in windows 8.1

Here is the code, enjoy!

async void dataTransferMgr_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            DataRequest request = args.Request;
            request.Data.Properties.Title = "Title";
            request.Data.Properties.Description = "brief description";
            request.Data.SetText("detailed information");

            
            RandomAccessStreamReference imageStreamRef = await ScreenshotToStreamReferenceAsync(yourChartControlName);
            request.Data.Properties.Thumbnail = imageStreamRef;
            request.Data.SetBitmap(imageStreamRef);

        }

private async Task ScreenshotToStreamAsync(FrameworkElement element, IRandomAccessStream stream)
{
var renderTargetBitmap = new Windows.UI.Xaml.Media.Imaging.RenderTargetBitmap();
await renderTargetBitmap.RenderAsync(element);

var pixelBuffer = await renderTargetBitmap.GetPixelsAsync();

var dpi = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;

var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);
encoder.SetPixelData(
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Ignore,
(uint)renderTargetBitmap.PixelWidth,
(uint)renderTargetBitmap.PixelHeight,
dpi,
dpi,
pixelBuffer.ToArray());

await encoder.FlushAsync();
}

private async Task<RandomAccessStreamReference> ScreenshotToStreamReferenceAsync(FrameworkElement element)
{
var ms = new InMemoryRandomAccessStream();
await ScreenshotToStreamAsync(element, ms);
ms.Seek(0);
return RandomAccessStreamReference.CreateFromStream(ms);
}


Tags
Chart for XAML
Asked by
Thanaphon
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Thanaphon
Top achievements
Rank 1
Abdu
Top achievements
Rank 1
Share this question
or