回答編集履歴

1

具体的な内容を追記しました。

2017/07/09 08:31

投稿

退会済みユーザー
test CHANGED
@@ -43,3 +43,181 @@
43
43
 
44
44
 
45
45
  他に MessageBox.Show(...); も使えると思います。
46
+
47
+
48
+
49
+ ---
50
+
51
+ 追記
52
+
53
+ 最新の Visual Studio ダウンロードしてきました。
54
+
55
+ ユニバーサルアプリは初めてですがとりあえず。。。
56
+
57
+
58
+
59
+ 手順
60
+
61
+ 1. Visual Studio で新規プロジェクトを作成(ユニバーサルアプリ)
62
+
63
+ 2. MainPage.xaml を開く
64
+
65
+ 3. ツールボックスから Button と TextBox をページにドラッグ。
66
+
67
+ 4. Button と TextBox を適当に配置・サイズ調整。
68
+
69
+ 5. Button をダブルクリック。(コード画面になってイベントハンドラが作成されます)
70
+
71
+ 6. イベントハンドラにコードを書く。
72
+
73
+
74
+
75
+ コードを書く際、注意点があります。
76
+
77
+ ・HttpClient や HttpRequestMessage を使う場合、最初に using System.Net.Http; を書く必要があります。
78
+
79
+ ・await を使う場合、関数に async を書く必要があります。
80
+
81
+
82
+
83
+ MainPage.xaml
84
+
85
+ ```XAML
86
+
87
+ <Page
88
+
89
+ x:Class="App1.MainPage"
90
+
91
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
92
+
93
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
94
+
95
+ xmlns:local="using:App1"
96
+
97
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
98
+
99
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
100
+
101
+ mc:Ignorable="d">
102
+
103
+
104
+
105
+ <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
106
+
107
+ <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top" Click="button_Click"/>
108
+
109
+ <TextBox x:Name="textBox" HorizontalAlignment="Left" Margin="10,73,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="340" Height="276"/>
110
+
111
+ </Grid>
112
+
113
+ </Page>
114
+
115
+ ```
116
+
117
+
118
+
119
+ MainPage.xaml.cs
120
+
121
+ ```C#
122
+
123
+ using System;
124
+
125
+ using System.Collections.Generic;
126
+
127
+ using System.IO;
128
+
129
+ using System.Linq;
130
+
131
+ using System.Runtime.InteropServices.WindowsRuntime;
132
+
133
+ using Windows.Foundation;
134
+
135
+ using Windows.Foundation.Collections;
136
+
137
+ using Windows.UI.Xaml;
138
+
139
+ using Windows.UI.Xaml.Controls;
140
+
141
+ using Windows.UI.Xaml.Controls.Primitives;
142
+
143
+ using Windows.UI.Xaml.Data;
144
+
145
+ using Windows.UI.Xaml.Input;
146
+
147
+ using Windows.UI.Xaml.Media;
148
+
149
+ using Windows.UI.Xaml.Navigation;
150
+
151
+ using System.Net.Http;
152
+
153
+
154
+
155
+ namespace App1
156
+
157
+ {
158
+
159
+ public sealed partial class MainPage : Page
160
+
161
+ {
162
+
163
+ public MainPage()
164
+
165
+ {
166
+
167
+ this.InitializeComponent();
168
+
169
+ }
170
+
171
+
172
+
173
+ private async void button_Click(object sender, RoutedEventArgs e)
174
+
175
+ {
176
+
177
+ Uri endpointUri = new Uri("https://teratail.com/");
178
+
179
+ var method = "GET";
180
+
181
+ var path = "/";
182
+
183
+ var query = "";
184
+
185
+
186
+
187
+ using (var client = new HttpClient())
188
+
189
+ using (var request = new HttpRequestMessage(new HttpMethod(method), path + query))
190
+
191
+ {
192
+
193
+ client.BaseAddress = endpointUri;
194
+
195
+ var message = await client.SendAsync(request);
196
+
197
+ var response = await message.Content.ReadAsStringAsync();
198
+
199
+ this.textBox.Text = response;
200
+
201
+ }
202
+
203
+ }
204
+
205
+ }
206
+
207
+ }
208
+
209
+ ```
210
+
211
+
212
+
213
+ しかし、改めて見てみると、ユニバーサルアプリ、初心者にはいろいろハードル高すぎですね。。。
214
+
215
+ これが理想形の開発環境だと言うことは分かるのですが。。。
216
+
217
+
218
+
219
+ とりあえず、Amazonとかで、何か初心者向けの本とか買ってみた方が良いと思います。
220
+
221
+ 私が初心者のころは、かたっぱしに本を買って、試行錯誤してました。
222
+
223
+ めげずにがんばってくださいね。