How to share the image from program to social media(Facebook,Telegram and other)?

Masha0307 41 Reputation points
2021-07-05T19:22:44.52+00:00

Hello. I make a screenshot on page and I want to share it to social media. I do not know how to share image to the social media. I know only how to share text, but I need to share image.Please help me to share screenshot from program

 <ContentPage.Content>
        <StackLayout HeightRequest="30" WidthRequest="30">

            <StackLayout x:Name="header">
                <Frame
                    Padding="3"
                    BackgroundColor="White"
                    BorderColor="#DBDBDB"
                    CornerRadius="15"
                    HasShadow="False">
                    <StackLayout Orientation="Horizontal">
                        <StackLayout
                            Margin="5,0,0,0"
                            HorizontalOptions="Start"
                            Orientation="Horizontal">

                            <StackLayout VerticalOptions="Center">
                                <Label
                                    FontSize="16"
                                    HorizontalOptions="Start"
                                    Text="USD"
                                    TextColor="Black" />
                                <Label
                                    FontSize="10"
                                    HorizontalOptions="Start"
                                    Text="US Dollar"
                                    TextColor="Black" />
                            </StackLayout>


                        </StackLayout>

                    </StackLayout>
                </Frame>
            </StackLayout>

            <Button x:Name="ShareButton" Text="Share" />
            <Image x:Name="result" />
        </StackLayout>
    </ContentPage.Content>



 public async void Button_Clicked(Object o,EventArgs e)
        {
            var image =await header.CaptureImageAsync();
            result.Source = ImageSource.FromStream(() => image);

        }

It is code how I make screenshot.Please help me to share image from program to social media

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 29,381 Reputation points Microsoft Vendor
    2021-07-06T05:33:08.91+00:00

    Hello,
    Welcome to our Microsoft Q&A platform!
    You can save image and then use Xamarin.Essentials Share like the following code

    string filePath = model.PhotoPath;//the path you saved  
    string fileType = "image/jpeg";  
    ShareFile fileToShare = new ShareFile(filePath, fileMimeType);  
    ShareFileRequest shareRequest = new ShareFileRequest(fileToShare);  
    await Share.RequestAsync(shareRequest);  
    

    For more information you can refer to:
    https://github.com/xamarin/Essentials/issues/424

    Best Regards,
    Wenyan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments