Xamarin.Forms 个用于在社交媒体中分享文本的应用程序
Xamarin.Forms applications for sharing a text in social media
我需要逐步演示如何开发 Xamarin.Forms 在社交媒体中共享文本的应用程序。我正在使用 Visual Studio 2019.
谢谢
我找到了一个 GitHub 存储库 GitHub and an article Article and YouTube video YouTube。 在此提醒您,本站不是为了谁给您写一百行代码。只问错误或问题。
在 Xamarin.Essentials, there is a Share class 中使应用程序能够与设备上的其他应用程序共享文本和 Web 链接等数据。
例如:
using Xamarin.Essentials;
public class ShareTest
{
public async Task ShareText(string text)
{
await Share.RequestAsync(new ShareTextRequest
{
Text = text,
Title = "Share Text"
});
}
public async Task ShareUri(string uri)
{
await Share.RequestAsync(new ShareTextRequest
{
Uri = uri,
Title = "Share Web Link"
});
}
}
Thank you for your contributions but here is my code for your kind help.
Please put me true because I'm new in Xamarin.Forms.
This is my TextPage.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Manytext.File.TextPage"
Title="Title">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
<ContentView>
<Label Text="Subheading"
HorizontalOptions="CenterAndExpand"
VerticalOptions="Center" />
</ContentView>
</StackLayout>
<ScrollView Grid.Row="1">
<StackLayout Orientation="Vertical" Padding="16,10,16,10" Spacing="10">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Button x:Name="ButtonShare"
Clicked="ShareText_OnClicked"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Text="Share" />
</StackLayout>
</ScrollView>
</Grid>
</ContentPage>
This is my TextPage.xaml.cs:
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xamarin.Essentials;
namespace Manytext.File
{
public partial class TextPage : ContentPage
{
public TextPage()
{
InitializeComponent();
}
private async void ShareText_OnClicked(object sender, EventArgs e)
{
await Share.RequestAsync(new ShareTextRequest
{
Title = "Share!"
});
}
}
}
我需要逐步演示如何开发 Xamarin.Forms 在社交媒体中共享文本的应用程序。我正在使用 Visual Studio 2019.
谢谢
我找到了一个 GitHub 存储库 GitHub and an article Article and YouTube video YouTube。 在此提醒您,本站不是为了谁给您写一百行代码。只问错误或问题。
在 Xamarin.Essentials, there is a Share class 中使应用程序能够与设备上的其他应用程序共享文本和 Web 链接等数据。
例如:
using Xamarin.Essentials;
public class ShareTest
{
public async Task ShareText(string text)
{
await Share.RequestAsync(new ShareTextRequest
{
Text = text,
Title = "Share Text"
});
}
public async Task ShareUri(string uri)
{
await Share.RequestAsync(new ShareTextRequest
{
Uri = uri,
Title = "Share Web Link"
});
}
}
Thank you for your contributions but here is my code for your kind help.
Please put me true because I'm new in Xamarin.Forms.
This is my TextPage.xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Manytext.File.TextPage"
Title="Title">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center" VerticalOptions="Center">
<ContentView>
<Label Text="Subheading"
HorizontalOptions="CenterAndExpand"
VerticalOptions="Center" />
</ContentView>
</StackLayout>
<ScrollView Grid.Row="1">
<StackLayout Orientation="Vertical" Padding="16,10,16,10" Spacing="10">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Label Text="Many text is here">
<Button x:Name="ButtonShare"
Clicked="ShareText_OnClicked"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
Text="Share" />
</StackLayout>
</ScrollView>
</Grid>
</ContentPage>
This is my TextPage.xaml.cs:
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xamarin.Essentials;
namespace Manytext.File
{
public partial class TextPage : ContentPage
{
public TextPage()
{
InitializeComponent();
}
private async void ShareText_OnClicked(object sender, EventArgs e)
{
await Share.RequestAsync(new ShareTextRequest
{
Title = "Share!"
});
}
}
}