MainWindow.xaml
<Window x:Class="WpfApplication6.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="250" Width="425">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" LastChildFill="True">
<Button DockPanel.Dock="Right" Click="Button_Click">Get</Button>
<TextBox DockPanel.Dock="Right" Name="urlTextBox"/>
</DockPanel>
<TextBox Grid.Row="1" Name="textBox1"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"/>
</Grid>
</Window>
MainWindow.xaml.cs
using System.Net.Http;using System.Threading.Tasks;
using System.Windows;
namespace WpfApplication6
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
HttpClient client = new HttpClient();
Task<string> task = client.GetStringAsync(this.urlTextBox.Text);
this.textBox1.Text = task.Result;
}
}
}
0 件のコメント:
コメントを投稿