SlideShare a Scribd company logo
1 of 13
Download to read offline
4시간만에 따라해보는 Windows 10 앱 개발 샘플코드
김영욱 / Microsoft
Evangelist / youngwook@outlook.com
1. SplitView의 추가
<SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False">
<SplitView.Pane>
<StackPanel Background="Gray">
<Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="&#xE700;"
Width="50" Height="50" Background="Transparent"/>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnHome" FontFamily="Segoe MDL2 Assets" Content="&#xE825;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Home" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnStoredBook" FontFamily="Segoe MDL2 Assets" Content="&#xE10F;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Book List" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content="&#xE1D6;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
</SplitView.Content>
</SplitView>
2. Content의 추가
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBox x:Name="txtKeyword" Width="128"/>
<Button x:Name="txtSearch" Content="Search"/>
<Button x:Name="txtStoredBooks" Content="저장된 책 보기"/>
</StackPanel>
<ListBox x:Name="lstBooks" Height="700">
<StackPanel Orientation="Horizontal" Height="300">
<Image x:Name="image"
Source="http://t1.daumcdn.net/thumb/R155x225/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fbook%2FKOR9788952756107%3Fmoddttm=20
150728062824"/>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="20" Text="책제목" FontWeight="Bold" HorizontalAlignment="Left"/>
<TextBlock x:Name="textBlock" FontSize="15" Text=" 1969년 12월 24일에 스코틀랜드 코트브리지에서
출생하였다. 현재는 스코틀랜드의 글래스고우에 거주하고 있으며 그의 작품은 최근 10년 동안 미국에서 활동한 영국 출신 작가의 작품 중
가장 많이 팔렸다. 대표작으로 [The Authority], [Ultimates 1 and 2], [Wanted], [Marvel Knights Spider-Man], [Ultimate Fantastic Four] 그리고
[Civil War]가 있다. 2007년 8월 스탠리 상을 받았다. 2008년 그의 원작을 바탕으로 한 영화 [Wanted] 가 개봉되었다." TextWrapping="Wrap"
Width="300"/>
</StackPanel>
</StackPanel>
</ListBox>
</StackPanel>
3. HamburgerButton 이벤트 핸들러 추가
private void HamburgerButton_Click(object sender, RoutedEventArgs e)
{
MySplitView.IsPaneOpen = !MySplitView.IsPaneOpen;
}
4. App Bar의 추가
<Page.BottomAppBar>
<AppBar IsOpen="False" Name="appbarMain">
<AppBarButton Icon="Add"/>
</AppBar>
</Page.BottomAppBar>
5. Daum API 정보의 설정
private string BOOK_SEARCH_URL = "https://apis.daum.net/search/book?apikey={0}&q={1}&output={2}";
private string API_KEY = "525d690b65911bfe2dadea15fb42bc32";//"0a927a3a0cdc03c7094547b8d50f7486";
private string OUTPUT = "xml";
6. Name Space 의 추가
using System.Net.Http;
using System.Xml.Linq;
7. Networking
string temp = string.Format(BOOK_SEARCH_URL, API_KEY, txtKeyword.Text, OUTPUT);
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
HttpResponseMessage response = await client.GetAsync(temp);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
XDocument xDoc = XDocument.Parse(responseBody);
8. Entity Class
class BookItem
{
public Int64 Id { get; set; }
public string Title { get; set; }
public string Category { get; set; }
public string ImageUrl { get; set; }
public string Description { get; set; }
}
9. Linq
var books = from BookItem in xDoc.Descendants("item")
select new BookItem
{
Title = (string)BookItem.Element("title"),
Category = (string)BookItem.Element("category"),
ImageUrl = (string)BookItem.Element("cover_l_url"),
Description = (string)BookItem.Element("description")
};
var booklist = books.ToList();
lstBooks.ItemsSource = booklist;
10. Adaptive UI
this.SizeChanged += (s, e) =>
{
var state = "VisualState000";
if (e.NewSize.Width > 800)
state = "VisualState800";
VisualStateManager.GoToState(this, state, true);
};
11. Binding
<ListBox x:Name="lstBooks" Height="700">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="300">
<Image x:Name="image" Source="{Binding ImageUrl}"/>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/>
<TextBlock x:Name="textBlock" FontSize="15" Text="{Binding Description}" TextWrapping="Wrap"
Width="300"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
12. StoredBook.xaml
<Page.BottomAppBar>
<AppBar IsOpen="True" Name="appbarMain">
<StackPanel Orientation="Horizontal">
<AppBarButton Icon="BackToWindow"/>
<AppBarButton Icon="Delete"/>
</StackPanel>
</AppBar>
</Page.BottomAppBar>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical">
<ListBox Name="lstBooks" Height="700">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Width="500" Height="300">
<Image Source="{Binding ImageUrl}"/>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/>
<TextBlock FontSize="15" Text="{Binding Description}" TextWrapping="Wrap" Width="300"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
13. SQLitePCL 추가
14. SQLIte Namespace 추가
using SQLitePCL;
15. App Member 변수 추가
public static SQLiteConnection SQLCon;
16. 데이터베이스 연결
this.InitializeComponent();
this.Suspending += OnSuspending;
SQLCon = new SQLiteConnection("Master.db");
string sql = @"CREATE TABLE IF NOT EXISTS
Books(Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Title VARCHAR(140),
Category VARCHAR(100),
ImageUrl VARCHAR(400),
Description VARCHAR(500)
);";
var statement = SQLCon.Prepare(sql);
statement.Step();
실행시 오류 발생하면
SQLite for Universal App Platform를 참조에서 추가한다.
17. Main Page SQLite Namespace 추가
using SQLitePCL;
18. 생성자에 Database 객체 가져오기
private SQLiteConnection Db = App.SQLCon;
19. 이벤트 핸들러에 코드 추가.
if (lstBooks.SelectedItem == null)
return;
var bookItem = (BookItem)lstBooks.SelectedItem;
try
{
using (var book = Db.Prepare("INSERT INTO Books(Title, Category, ImageUrl, Description) VALUES(?,?,?,?)"))
{
book.Bind(1, bookItem.Title);
book.Bind(2, bookItem.Category);
book.Bind(3, bookItem.ImageUrl);
book.Bind(4, bookItem.Description);
book.Step();
}
}
catch (Exception ex)
{
}
20. 조회 부분 작성
private void txtStoredBooks_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(StoredBook), null);
}
21. StoredBook.xaml 작업
using SQLitePCL;
SQLiteConnection Db;
Db = App.SQLCon;
22. 조회하는 코드
private void DataLoading()
{
using (var statement = Db.Prepare("SELECT Id, Title, Category, ImageUrl, Description FROM Books"))
{
List<BookItem> books = new List<BookItem>();
while (statement.Step() == SQLiteResult.ROW)
{
BookItem book = new BookItem();
book.Id = (Int64)statement[0];
book.Title = (string)statement[1];
book.Category = (string)statement[2];
book.ImageUrl = (string)statement[3];
book.Description = (string)statement[4];
books.Add(book);
}
lstBooks.ItemsSource = books;
if(lstBooks.Items.Count != 0)
{
lstBooks.SelectedIndex = 0;
}
}
}
23. 돌아가기 버튼의 기능 추가
this.Frame.GoBack();
24. 삭제 기능의 추가
if (lstBooks.SelectedItem == null)
return;
var bookItem = (BookItem)lstBooks.SelectedItem;
Int64 id = bookItem.Id;
var statement = Db.Prepare("DELETE FROM books WHERE Id=?");
statement.Bind(1, id);
statement.Step();
DataLoading();
25. 22. Notification
using Windows.UI.Notifications;
var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
var toeastElement = notificationXml.GetElementsByTagName("text");
toeastElement[0].AppendChild(notificationXml.CreateTextNode(bookItem.Title + "이(가) 추가 되었습니다."));
var toastNotification = new ToastNotification(notificationXml);
ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
26. Adaptive UI VisualStateManager를 사용하는 방법
<VisualStateManager.VisualStateGroups>
<!-- Within this view, the splitview is being optimized for window size using responsive techniques -->
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="MySplitView.DisplayMode" Value="Inline" />
<Setter Target="MySplitView.IsPaneOpen" Value="True" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
27. Adaptive UI에서 WrapPanel을 사용하는 부분
<StackPanel Background="Gray">
<Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="&#xE700;"
Width="50" Height="50" Background="Transparent" Click="HamburgerButton_Click"/>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnHome" FontFamily="Segoe MDL2 Assets" Content="&#xE825;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Home" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="btnStoredBook" FontFamily="Segoe MDL2 Assets" Content="&#xE10F;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Book List" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content="&#xE1D6;"
Width="50" Height="50" Background="Transparent"/>
<TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" />
</StackPanel>
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBox x:Name="txtKeyword" Width="128"/>
<Button x:Name="txtSearch" Content="Search"/>
<Button x:Name="txtStoredBooks" Content="저장된 책 보기" Click="txtStoredBooks_Click"/>
</StackPanel>
<ListView Name="lstBooks" ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" ItemHeight="200" ItemWidth="400"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Height="300">
<Image x:Name="image" Source="{Binding ImageUrl}"/>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/>
<TextBlock x:Name="textBlock" FontSize="15" Text="{Binding Description}" TextWrapping="Wrap"
Width="300"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
28. Adaptive Code
var api = "Windows.Phone.UI.Input.HardwareButtons";
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(api))
{
Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed;
}
private void HardwareButtons_CameraPressed(object sender, Windows.Phone.UI.Input.CameraEventArgs e)
{
this.Frame.GoBack();
}

More Related Content

What's hot

"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил АнохинFwdays
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Fwdays
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query OptimizationMongoDB
 
The Principle of Hybrid App.
The Principle of Hybrid App.The Principle of Hybrid App.
The Principle of Hybrid App.musart Park
 
Mule esb – connecting to ms sql db
Mule esb – connecting to ms sql dbMule esb – connecting to ms sql db
Mule esb – connecting to ms sql dbGunjan Deshmukh
 
Better Bullshit Driven Development [SeleniumCamp 2017]
Better Bullshit Driven Development [SeleniumCamp 2017]Better Bullshit Driven Development [SeleniumCamp 2017]
Better Bullshit Driven Development [SeleniumCamp 2017]automician
 
SenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioSenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioNils Dehl
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185Mahmoud Samir Fayed
 
Customizing the list control - Sencha Touch mobile web application
Customizing the list control - Sencha Touch mobile web applicationCustomizing the list control - Sencha Touch mobile web application
Customizing the list control - Sencha Touch mobile web applicationJoseph Khan
 
The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202Mahmoud Samir Fayed
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tableMahabubur Rahaman
 

What's hot (20)

Javascript 2
Javascript 2Javascript 2
Javascript 2
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"
 
Indexing & Query Optimization
Indexing & Query OptimizationIndexing & Query Optimization
Indexing & Query Optimization
 
PHP with MYSQL
PHP with MYSQLPHP with MYSQL
PHP with MYSQL
 
Using database in android
Using database in androidUsing database in android
Using database in android
 
J query1
J query1J query1
J query1
 
The Principle of Hybrid App.
The Principle of Hybrid App.The Principle of Hybrid App.
The Principle of Hybrid App.
 
J query
J queryJ query
J query
 
Mule esb – connecting to ms sql db
Mule esb – connecting to ms sql dbMule esb – connecting to ms sql db
Mule esb – connecting to ms sql db
 
DOM and Events
DOM and EventsDOM and Events
DOM and Events
 
Better Bullshit Driven Development [SeleniumCamp 2017]
Better Bullshit Driven Development [SeleniumCamp 2017]Better Bullshit Driven Development [SeleniumCamp 2017]
Better Bullshit Driven Development [SeleniumCamp 2017]
 
SenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.ioSenchaTouch 2 and Sencha.io
SenchaTouch 2 and Sencha.io
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185
 
Jquery
JqueryJquery
Jquery
 
Customizing the list control - Sencha Touch mobile web application
Customizing the list control - Sencha Touch mobile web applicationCustomizing the list control - Sencha Touch mobile web application
Customizing the list control - Sencha Touch mobile web application
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202The Ring programming language version 1.8 book - Part 49 of 202
The Ring programming language version 1.8 book - Part 49 of 202
 
supporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered tablesupporting t-sql scripts for Heap vs clustered table
supporting t-sql scripts for Heap vs clustered table
 
Java
JavaJava
Java
 

Viewers also liked

DLD TLV Cognitive Services: The Brains Behind Your Bot
DLD TLV Cognitive Services:The Brains Behind Your BotDLD TLV Cognitive Services:The Brains Behind Your Bot
DLD TLV Cognitive Services: The Brains Behind Your BotAaron (Ari) Bornstein
 
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7Sérgio Sacani
 
Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Daisuke Sugai
 
Chuck Norris Xamarin
Chuck Norris XamarinChuck Norris Xamarin
Chuck Norris XamarinJames Quick
 
Windows10 gamedevoverviewexcludingvideos
Windows10 gamedevoverviewexcludingvideosWindows10 gamedevoverviewexcludingvideos
Windows10 gamedevoverviewexcludingvideosJaime Rodriguez Carrete
 
Καβάφης η ζωή και το εργο του
Καβάφης   η ζωή και το εργο τουΚαβάφης   η ζωή και το εργο του
Καβάφης η ζωή και το εργο τουStella Sigourtsidou
 
2016 slingshot foilonly_presentation
2016 slingshot foilonly_presentation2016 slingshot foilonly_presentation
2016 slingshot foilonly_presentationGordon Freeman
 
Presentación funamentos 1 ev
Presentación funamentos 1 evPresentación funamentos 1 ev
Presentación funamentos 1 evmartamanso04
 
Frontline extension system
Frontline extension systemFrontline extension system
Frontline extension systemAbhinav Vivek
 
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?MongoDB
 
Develop hololens
Develop hololensDevelop hololens
Develop hololensJames Quick
 
Extension system of icar &amp; sau and ngos
Extension system of icar &amp; sau and ngosExtension system of icar &amp; sau and ngos
Extension system of icar &amp; sau and ngosYagnesh sondarva
 

Viewers also liked (17)

Options for global agricultural trade after Nairobi: Global solutions or nati...
Options for global agricultural trade after Nairobi: Global solutions or nati...Options for global agricultural trade after Nairobi: Global solutions or nati...
Options for global agricultural trade after Nairobi: Global solutions or nati...
 
DLD TLV Cognitive Services: The Brains Behind Your Bot
DLD TLV Cognitive Services:The Brains Behind Your BotDLD TLV Cognitive Services:The Brains Behind Your Bot
DLD TLV Cognitive Services: The Brains Behind Your Bot
 
mabel_agoba_cv
mabel_agoba_cvmabel_agoba_cv
mabel_agoba_cv
 
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7
An extreme starburst_in_the_core_of_a_rich_galaxy_cluster_at_z_1_7
 
Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方Apple Push Notification Serviceの使い方
Apple Push Notification Serviceの使い方
 
Chuck Norris Xamarin
Chuck Norris XamarinChuck Norris Xamarin
Chuck Norris Xamarin
 
Windows10 gamedevoverviewexcludingvideos
Windows10 gamedevoverviewexcludingvideosWindows10 gamedevoverviewexcludingvideos
Windows10 gamedevoverviewexcludingvideos
 
Καβάφης η ζωή και το εργο του
Καβάφης   η ζωή και το εργο τουΚαβάφης   η ζωή και το εργο του
Καβάφης η ζωή και το εργο του
 
2016 slingshot foilonly_presentation
2016 slingshot foilonly_presentation2016 slingshot foilonly_presentation
2016 slingshot foilonly_presentation
 
Presentación funamentos 1 ev
Presentación funamentos 1 evPresentación funamentos 1 ev
Presentación funamentos 1 ev
 
Frontline extension system
Frontline extension systemFrontline extension system
Frontline extension system
 
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
MongoDB Evenings Minneapolis: MongoDB is Cool But When Should I Use It?
 
Develop hololens
Develop hololensDevelop hololens
Develop hololens
 
Jan 2017 resume
Jan 2017 resumeJan 2017 resume
Jan 2017 resume
 
Extension system of icar &amp; sau and ngos
Extension system of icar &amp; sau and ngosExtension system of icar &amp; sau and ngos
Extension system of icar &amp; sau and ngos
 
Friendship
FriendshipFriendship
Friendship
 
Meta programlar
Meta programlarMeta programlar
Meta programlar
 

Similar to 4시간만에 따라해보는 Windows 10 앱 개발 샘플코드

Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple DevelopersPeter Friese
 
Arquitetando seu app Android com Jetpack
Arquitetando seu app Android com JetpackArquitetando seu app Android com Jetpack
Arquitetando seu app Android com JetpackNelson Glauber Leal
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesPeter Friese
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneRafael Felix da Silva
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseHeiko Behrens
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScriptAndrew Dupont
 
Building DSLs with Groovy
Building DSLs with GroovyBuilding DSLs with Groovy
Building DSLs with GroovySten Anderson
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App DevelopmentKetan Raval
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsCédric Hüsler
 
Arquitetando seu aplicativo Android com Jetpack
Arquitetando seu aplicativo Android com JetpackArquitetando seu aplicativo Android com Jetpack
Arquitetando seu aplicativo Android com JetpackNelson Glauber Leal
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
Practical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich ClientsPractical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich ClientsRichard Bair
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQueryPhDBrown
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptLaurence Svekis ✔
 

Similar to 4시간만에 따라해보는 Windows 10 앱 개발 샘플코드 (20)

Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple Developers
 
Arquitetando seu app Android com Jetpack
Arquitetando seu app Android com JetpackArquitetando seu app Android com Jetpack
Arquitetando seu app Android com Jetpack
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroes
 
Aplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com BackboneAplicacoes dinamicas Rails com Backbone
Aplicacoes dinamicas Rails com Backbone
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 
Prototype UI
Prototype UIPrototype UI
Prototype UI
 
Writing Maintainable JavaScript
Writing Maintainable JavaScriptWriting Maintainable JavaScript
Writing Maintainable JavaScript
 
Building DSLs with Groovy
Building DSLs with GroovyBuilding DSLs with Groovy
Building DSLs with Groovy
 
jQuery
jQueryjQuery
jQuery
 
Swift Tableview iOS App Development
Swift Tableview iOS App DevelopmentSwift Tableview iOS App Development
Swift Tableview iOS App Development
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - Highlights
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Arquitetando seu aplicativo Android com Jetpack
Arquitetando seu aplicativo Android com JetpackArquitetando seu aplicativo Android com Jetpack
Arquitetando seu aplicativo Android com Jetpack
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Prototype UI Intro
Prototype UI IntroPrototype UI Intro
Prototype UI Intro
 
Practical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich ClientsPractical Experience Building JavaFX Rich Clients
Practical Experience Building JavaFX Rich Clients
 
droidQuery: The Android port of jQuery
droidQuery: The Android port of jQuerydroidQuery: The Android port of jQuery
droidQuery: The Android port of jQuery
 
JavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScriptJavaScript Objects and OOP Programming with JavaScript
JavaScript Objects and OOP Programming with JavaScript
 

More from 영욱 김

20170701 microsoft 오픈소스의 종류와 활용법
20170701 microsoft 오픈소스의 종류와 활용법20170701 microsoft 오픈소스의 종류와 활용법
20170701 microsoft 오픈소스의 종류와 활용법영욱 김
 
20160511 Azure Datacenter
20160511 Azure Datacenter20160511 Azure Datacenter
20160511 Azure Datacenter영욱 김
 
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략영욱 김
 
20160412 이미테이션 게임과 it기업들의 인공지능
20160412 이미테이션 게임과 it기업들의 인공지능20160412 이미테이션 게임과 it기업들의 인공지능
20160412 이미테이션 게임과 it기업들의 인공지능영욱 김
 
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경영욱 김
 
20160408 smart farm
20160408 smart farm20160408 smart farm
20160408 smart farm영욱 김
 
20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발영욱 김
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발영욱 김
 
20150912 windows 10 앱 tips tricks
20150912 windows 10 앱 tips  tricks20150912 windows 10 앱 tips  tricks
20150912 windows 10 앱 tips tricks영욱 김
 
20150912 IoT 디바이스를 위한 windows 10 iot core 입문
20150912 IoT 디바이스를 위한 windows 10 iot core 입문20150912 IoT 디바이스를 위한 windows 10 iot core 입문
20150912 IoT 디바이스를 위한 windows 10 iot core 입문영욱 김
 
20150912 Adaptive UI 권영철
20150912 Adaptive UI 권영철20150912 Adaptive UI 권영철
20150912 Adaptive UI 권영철영욱 김
 
201500912 Hello Windows 10
201500912 Hello Windows 10201500912 Hello Windows 10
201500912 Hello Windows 10영욱 김
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발영욱 김
 
Arduino Coding
Arduino CodingArduino Coding
Arduino Coding영욱 김
 
C Language For Arduino
C Language For ArduinoC Language For Arduino
C Language For Arduino영욱 김
 
IoT Devices And Arduino
IoT Devices And ArduinoIoT Devices And Arduino
IoT Devices And Arduino영욱 김
 
20150212 사례로보는 Microsoft IoT와 서비스 개발
20150212 사례로보는 Microsoft IoT와 서비스 개발20150212 사례로보는 Microsoft IoT와 서비스 개발
20150212 사례로보는 Microsoft IoT와 서비스 개발영욱 김
 
20150207 Node.js on Azure - MeltingPot seminar in Busan
20150207 Node.js on Azure - MeltingPot seminar in Busan20150207 Node.js on Azure - MeltingPot seminar in Busan
20150207 Node.js on Azure - MeltingPot seminar in Busan영욱 김
 
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게 크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게 영욱 김
 
20141216 멜팅팟 부산 세션 i - microsoft 사물인터넷
20141216 멜팅팟 부산   세션 i - microsoft 사물인터넷20141216 멜팅팟 부산   세션 i - microsoft 사물인터넷
20141216 멜팅팟 부산 세션 i - microsoft 사물인터넷영욱 김
 

More from 영욱 김 (20)

20170701 microsoft 오픈소스의 종류와 활용법
20170701 microsoft 오픈소스의 종류와 활용법20170701 microsoft 오픈소스의 종류와 활용법
20170701 microsoft 오픈소스의 종류와 활용법
 
20160511 Azure Datacenter
20160511 Azure Datacenter20160511 Azure Datacenter
20160511 Azure Datacenter
 
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략
20160511 azure를 기반으로한 인공지능 io t 생태계 구축 전략
 
20160412 이미테이션 게임과 it기업들의 인공지능
20160412 이미테이션 게임과 it기업들의 인공지능20160412 이미테이션 게임과 it기업들의 인공지능
20160412 이미테이션 게임과 it기업들의 인공지능
 
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경
20160409 서브라임텍스트 대신 visual studio code로 만들어 보는 웹 환경
 
20160408 smart farm
20160408 smart farm20160408 smart farm
20160408 smart farm
 
20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발20151117 IoT를 위한 서비스 구성과 개발
20151117 IoT를 위한 서비스 구성과 개발
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발
 
20150912 windows 10 앱 tips tricks
20150912 windows 10 앱 tips  tricks20150912 windows 10 앱 tips  tricks
20150912 windows 10 앱 tips tricks
 
20150912 IoT 디바이스를 위한 windows 10 iot core 입문
20150912 IoT 디바이스를 위한 windows 10 iot core 입문20150912 IoT 디바이스를 위한 windows 10 iot core 입문
20150912 IoT 디바이스를 위한 windows 10 iot core 입문
 
20150912 Adaptive UI 권영철
20150912 Adaptive UI 권영철20150912 Adaptive UI 권영철
20150912 Adaptive UI 권영철
 
201500912 Hello Windows 10
201500912 Hello Windows 10201500912 Hello Windows 10
201500912 Hello Windows 10
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Arduino Coding
Arduino CodingArduino Coding
Arduino Coding
 
C Language For Arduino
C Language For ArduinoC Language For Arduino
C Language For Arduino
 
IoT Devices And Arduino
IoT Devices And ArduinoIoT Devices And Arduino
IoT Devices And Arduino
 
20150212 사례로보는 Microsoft IoT와 서비스 개발
20150212 사례로보는 Microsoft IoT와 서비스 개발20150212 사례로보는 Microsoft IoT와 서비스 개발
20150212 사례로보는 Microsoft IoT와 서비스 개발
 
20150207 Node.js on Azure - MeltingPot seminar in Busan
20150207 Node.js on Azure - MeltingPot seminar in Busan20150207 Node.js on Azure - MeltingPot seminar in Busan
20150207 Node.js on Azure - MeltingPot seminar in Busan
 
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게 크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게
크로스 플랫폼 기술과 오픈소스로 진화하는 Microsoft의 개발자 생태게
 
20141216 멜팅팟 부산 세션 i - microsoft 사물인터넷
20141216 멜팅팟 부산   세션 i - microsoft 사물인터넷20141216 멜팅팟 부산   세션 i - microsoft 사물인터넷
20141216 멜팅팟 부산 세션 i - microsoft 사물인터넷
 

4시간만에 따라해보는 Windows 10 앱 개발 샘플코드

  • 1. 4시간만에 따라해보는 Windows 10 앱 개발 샘플코드 김영욱 / Microsoft Evangelist / youngwook@outlook.com 1. SplitView의 추가 <SplitView x:Name="MySplitView" DisplayMode="CompactOverlay" IsPaneOpen="False"> <SplitView.Pane> <StackPanel Background="Gray"> <Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="&#xE700;" Width="50" Height="50" Background="Transparent"/> <StackPanel Orientation="Horizontal"> <Button x:Name="btnHome" FontFamily="Segoe MDL2 Assets" Content="&#xE825;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Home" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="btnStoredBook" FontFamily="Segoe MDL2 Assets" Content="&#xE10F;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Book List" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content="&#xE1D6;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" /> </StackPanel> </StackPanel> </SplitView.Pane>
  • 2. <SplitView.Content> </SplitView.Content> </SplitView> 2. Content의 추가 <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <TextBox x:Name="txtKeyword" Width="128"/> <Button x:Name="txtSearch" Content="Search"/> <Button x:Name="txtStoredBooks" Content="저장된 책 보기"/> </StackPanel> <ListBox x:Name="lstBooks" Height="700"> <StackPanel Orientation="Horizontal" Height="300"> <Image x:Name="image" Source="http://t1.daumcdn.net/thumb/R155x225/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fbook%2FKOR9788952756107%3Fmoddttm=20 150728062824"/> <StackPanel Orientation="Vertical"> <TextBlock FontSize="20" Text="책제목" FontWeight="Bold" HorizontalAlignment="Left"/> <TextBlock x:Name="textBlock" FontSize="15" Text=" 1969년 12월 24일에 스코틀랜드 코트브리지에서 출생하였다. 현재는 스코틀랜드의 글래스고우에 거주하고 있으며 그의 작품은 최근 10년 동안 미국에서 활동한 영국 출신 작가의 작품 중 가장 많이 팔렸다. 대표작으로 [The Authority], [Ultimates 1 and 2], [Wanted], [Marvel Knights Spider-Man], [Ultimate Fantastic Four] 그리고 [Civil War]가 있다. 2007년 8월 스탠리 상을 받았다. 2008년 그의 원작을 바탕으로 한 영화 [Wanted] 가 개봉되었다." TextWrapping="Wrap" Width="300"/> </StackPanel> </StackPanel> </ListBox> </StackPanel> 3. HamburgerButton 이벤트 핸들러 추가 private void HamburgerButton_Click(object sender, RoutedEventArgs e) { MySplitView.IsPaneOpen = !MySplitView.IsPaneOpen; } 4. App Bar의 추가
  • 3. <Page.BottomAppBar> <AppBar IsOpen="False" Name="appbarMain"> <AppBarButton Icon="Add"/> </AppBar> </Page.BottomAppBar> 5. Daum API 정보의 설정 private string BOOK_SEARCH_URL = "https://apis.daum.net/search/book?apikey={0}&q={1}&output={2}"; private string API_KEY = "525d690b65911bfe2dadea15fb42bc32";//"0a927a3a0cdc03c7094547b8d50f7486"; private string OUTPUT = "xml"; 6. Name Space 의 추가 using System.Net.Http; using System.Xml.Linq; 7. Networking string temp = string.Format(BOOK_SEARCH_URL, API_KEY, txtKeyword.Text, OUTPUT); System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); HttpResponseMessage response = await client.GetAsync(temp); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); XDocument xDoc = XDocument.Parse(responseBody);
  • 4. 8. Entity Class class BookItem { public Int64 Id { get; set; } public string Title { get; set; } public string Category { get; set; } public string ImageUrl { get; set; } public string Description { get; set; } } 9. Linq var books = from BookItem in xDoc.Descendants("item") select new BookItem { Title = (string)BookItem.Element("title"), Category = (string)BookItem.Element("category"), ImageUrl = (string)BookItem.Element("cover_l_url"), Description = (string)BookItem.Element("description") }; var booklist = books.ToList(); lstBooks.ItemsSource = booklist;
  • 5. 10. Adaptive UI this.SizeChanged += (s, e) => { var state = "VisualState000"; if (e.NewSize.Width > 800) state = "VisualState800"; VisualStateManager.GoToState(this, state, true); }; 11. Binding <ListBox x:Name="lstBooks" Height="700"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="300"> <Image x:Name="image" Source="{Binding ImageUrl}"/> <StackPanel Orientation="Vertical"> <TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/> <TextBlock x:Name="textBlock" FontSize="15" Text="{Binding Description}" TextWrapping="Wrap" Width="300"/> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox>
  • 6. 12. StoredBook.xaml <Page.BottomAppBar> <AppBar IsOpen="True" Name="appbarMain"> <StackPanel Orientation="Horizontal"> <AppBarButton Icon="BackToWindow"/> <AppBarButton Icon="Delete"/> </StackPanel> </AppBar> </Page.BottomAppBar> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Orientation="Vertical"> <ListBox Name="lstBooks" Height="700"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Width="500" Height="300"> <Image Source="{Binding ImageUrl}"/> <StackPanel Orientation="Vertical"> <TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/> <TextBlock FontSize="15" Text="{Binding Description}" TextWrapping="Wrap" Width="300"/> </StackPanel> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </Grid> 13. SQLitePCL 추가 14. SQLIte Namespace 추가 using SQLitePCL;
  • 7. 15. App Member 변수 추가 public static SQLiteConnection SQLCon; 16. 데이터베이스 연결 this.InitializeComponent(); this.Suspending += OnSuspending; SQLCon = new SQLiteConnection("Master.db"); string sql = @"CREATE TABLE IF NOT EXISTS Books(Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Title VARCHAR(140), Category VARCHAR(100), ImageUrl VARCHAR(400), Description VARCHAR(500) );"; var statement = SQLCon.Prepare(sql); statement.Step(); 실행시 오류 발생하면 SQLite for Universal App Platform를 참조에서 추가한다. 17. Main Page SQLite Namespace 추가 using SQLitePCL; 18. 생성자에 Database 객체 가져오기 private SQLiteConnection Db = App.SQLCon;
  • 8. 19. 이벤트 핸들러에 코드 추가. if (lstBooks.SelectedItem == null) return; var bookItem = (BookItem)lstBooks.SelectedItem; try { using (var book = Db.Prepare("INSERT INTO Books(Title, Category, ImageUrl, Description) VALUES(?,?,?,?)")) { book.Bind(1, bookItem.Title); book.Bind(2, bookItem.Category); book.Bind(3, bookItem.ImageUrl); book.Bind(4, bookItem.Description); book.Step(); } } catch (Exception ex) { } 20. 조회 부분 작성 private void txtStoredBooks_Click(object sender, RoutedEventArgs e) { Frame.Navigate(typeof(StoredBook), null); }
  • 9. 21. StoredBook.xaml 작업 using SQLitePCL; SQLiteConnection Db; Db = App.SQLCon; 22. 조회하는 코드 private void DataLoading() { using (var statement = Db.Prepare("SELECT Id, Title, Category, ImageUrl, Description FROM Books")) { List<BookItem> books = new List<BookItem>(); while (statement.Step() == SQLiteResult.ROW) { BookItem book = new BookItem(); book.Id = (Int64)statement[0]; book.Title = (string)statement[1]; book.Category = (string)statement[2]; book.ImageUrl = (string)statement[3]; book.Description = (string)statement[4]; books.Add(book); } lstBooks.ItemsSource = books; if(lstBooks.Items.Count != 0) { lstBooks.SelectedIndex = 0; } }
  • 10. } 23. 돌아가기 버튼의 기능 추가 this.Frame.GoBack(); 24. 삭제 기능의 추가 if (lstBooks.SelectedItem == null) return; var bookItem = (BookItem)lstBooks.SelectedItem; Int64 id = bookItem.Id; var statement = Db.Prepare("DELETE FROM books WHERE Id=?"); statement.Bind(1, id); statement.Step(); DataLoading(); 25. 22. Notification using Windows.UI.Notifications; var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); var toeastElement = notificationXml.GetElementsByTagName("text"); toeastElement[0].AppendChild(notificationXml.CreateTextNode(bookItem.Title + "이(가) 추가 되었습니다.")); var toastNotification = new ToastNotification(notificationXml); ToastNotificationManager.CreateToastNotifier().Show(toastNotification);
  • 11. 26. Adaptive UI VisualStateManager를 사용하는 방법 <VisualStateManager.VisualStateGroups> <!-- Within this view, the splitview is being optimized for window size using responsive techniques --> <VisualStateGroup> <VisualState> <VisualState.StateTriggers> <AdaptiveTrigger MinWindowWidth="720" /> </VisualState.StateTriggers> <VisualState.Setters> <Setter Target="MySplitView.DisplayMode" Value="Inline" /> <Setter Target="MySplitView.IsPaneOpen" Value="True" /> </VisualState.Setters> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups>
  • 12. 27. Adaptive UI에서 WrapPanel을 사용하는 부분 <StackPanel Background="Gray"> <Button x:Name="HamburgerButton" FontFamily="Segoe MDL2 Assets" Content="&#xE700;" Width="50" Height="50" Background="Transparent" Click="HamburgerButton_Click"/> <StackPanel Orientation="Horizontal"> <Button x:Name="btnHome" FontFamily="Segoe MDL2 Assets" Content="&#xE825;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Home" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="btnStoredBook" FontFamily="Segoe MDL2 Assets" Content="&#xE10F;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Book List" FontSize="18" VerticalAlignment="Center" /> </StackPanel> <StackPanel Orientation="Horizontal"> <Button x:Name="MenuButton3" FontFamily="Segoe MDL2 Assets" Content="&#xE1D6;" Width="50" Height="50" Background="Transparent"/> <TextBlock Text="Button 3" FontSize="18" VerticalAlignment="Center" /> </StackPanel> </StackPanel> </SplitView.Pane> <SplitView.Content> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <TextBox x:Name="txtKeyword" Width="128"/> <Button x:Name="txtSearch" Content="Search"/> <Button x:Name="txtStoredBooks" Content="저장된 책 보기" Click="txtStoredBooks_Click"/> </StackPanel> <ListView Name="lstBooks" ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapGrid Orientation="Horizontal" ItemHeight="200" ItemWidth="400"/> </ItemsPanelTemplate> </ListView.ItemsPanel>
  • 13. <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style> </ListView.ItemContainerStyle> <ListView.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Height="300"> <Image x:Name="image" Source="{Binding ImageUrl}"/> <StackPanel Orientation="Vertical"> <TextBlock FontSize="20" Text="{Binding Title}" FontWeight="Bold" HorizontalAlignment="Left"/> <TextBlock x:Name="textBlock" FontSize="15" Text="{Binding Description}" TextWrapping="Wrap" Width="300"/> </StackPanel> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackPanel> 28. Adaptive Code var api = "Windows.Phone.UI.Input.HardwareButtons"; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(api)) { Windows.Phone.UI.Input.HardwareButtons.CameraPressed += HardwareButtons_CameraPressed; } private void HardwareButtons_CameraPressed(object sender, Windows.Phone.UI.Input.CameraEventArgs e) { this.Frame.GoBack(); }