AGENDA WINDOWS PRESENTATION FOUNDATION LEKTION 4. Statusbar Hyperlänkar WebBrowser TabControl Ribbon ListBox Data Template Resource Dictionary Style



Similar documents
WINDOWS PRESENTATION FOUNDATION LEKTION 3

MahApps est un projet OpenSource qui permet de faire de belles interfaces au style «Metro» avec Wpf

wpf5concat Start Microsoft Visual Studio. File New Project WPF Application, Name= wpf5concat OK.

InGenius Connector Enterprise Demo System for Microsoft Dynamics CRM

Relationships in WPF Applications

Microsoft Virtual Labs. Building Windows Presentation Foundation Applications - C# - Part 1

Viktigaste uppgift: Web Browser SSO

PRTK. Password Recovery ToolKit EFS (Encrypting File System)

Hands-On Lab. Building Applications in Silverlight 4 Module 8: Advanced OOB and MEF. Event Administrator Dashboard

Introduction to C#, Visual Studio and Windows Presentation Foundation

Interface Programmera mot interface Johan Eliasson Johan Eliasson Interface kan bryta beroendekedjor Skriv generell kod «Type» Class2 Interface

Installation guide. Uppsala University thesis template for Word

Design Suggestions for Danske Bank SE

openbim FM solutions and projects in Sweden Oslo, 11 September 2014 Client BIM requirements BIM in the State

Microsoft Migrating to Access 2010 from Access 2003

1. Create an account. The first step is to create an account in SSRK Prov. There are no account fees.

Performance and Usability Improvements for Massive Data Grids using Silverlight

Projektet Computer: Specifikation. Objektorienterad modellering och diskreta strukturer / design. Projektet Computer: Data. Projektet Computer: Test

1. WPF Tutorial Page 1 of 431 wpf-tutorial.com

Windows Presentation Foundation

Get started guide. Uppsala University thesis template for Word

This tutorial has been designed for all those readers who want to learn WPF and to apply it instantaneously in different type of applications.

WPF Learner s Guide to Head First C#

MicroStrategy Tips and Tricks

GOOGLE DOCS APPLICATION WORK WITH GOOGLE DOCUMENTS

Jag valde att använda Net-EPP_client.php från centralnic för att komma igång.

Windows Presentation Foundation Using C#

Microsoft Word 2007 Module 1

KFUPM. Web Content Management System powered by SharePoint

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Windows 10 Apps Development

Workshop 1: Can CM find common ground for HW & SW development?

Microsoft Office Word 2007 Training

Sweden National H.O.G. Rally July 2010

ComponentOne. Windows for WPF

Microsoft Migrating to Word 2010 from Word 2003

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Enter your User Id and Password and click the Log In button to launch the application.

Microsoft Office 2007

IBM idag. Johan Rittner VD IBM Svenska

Lösningsförslag till tentamen

Microsoft Excel 2013: Using a Data Entry Form

Microsoft + SOA = Sant? Joakim Linghall Principal System Engineer SOA and Business Process joakiml@microsoft.com

Microsoft Office Access 2007 Training

Data Binding with WPF: Binding to XML

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Boliden. Sustainable development

The Millistream News Format

Microsoft PowerPoint 2008

To Begin Customize Office

Step 2: Headings and Subheadings

Använd SAS för att bearbeta och analysera ditt data i Hadoop

Microsoft PowerPoint 2010

Lab 2 review PHP intro. MVC (Model View controller)

An Introduction to the Windows Presentation Foundation with the Model-View-ViewModel

Crystal Reports. For Visual Studio.NET. Designing and Viewing a Report in a Windows Application

SABINE. Sabine har en medvetet sparsmakad design som tål upprepning. Variationsmöjligheter finns i olika material och färger.

Ange om en aktivitet har medfört att en tjänsteresa har utförts med flyg under 2013, och i sådana fall antal gånger.

LUVIT Administration. Manual

Vet du redan nu att du vill studera på Emirates Academy kan du fylla i ansökan nedan och skicka till KILROY.

آموزش DataGrid در WPF به همراه صفحه بندي و جستجوي انتخابی. کلیک کن

Microsoft PowerPoint 2011

SAS Education Providing knowledge through global training and certification. SAS Foundation. Kursöversikt 2010

Quick Guide to the Cascade Server Content Management System (CMS)

Content Author's Reference and Cookbook

How To Use Excel 2010 On Windows 7 (Windows 7) On A Pc Or Mac) With A Microsoft Powerbook (Windows Xp) On Your Computer Or Macintosh (Windows) On Windows Xp (Windows 2007) On Microsoft Excel 2010

Defining Distributed Systems. Distribuerade system. Exemples of DS: Intranet. Exemples of DS: Internet. Exemples of DS: Mobile Computing

Mapping to the Windows Presentation Framework

How to Create a Newsletter Using Common Sense Software - Custom Design

Introduction to Microsoft Word 2008

1.) Click on Tasks it is located in the bottom left hand corner of your outlook Navigation Pane

Readme10_054.doc page 1 of 7

When you have decided what to include in your signature, you will need to open the signatures and stationery dialogue box:

BABIES PG st per förpackning, kan även beställas styckevis.

Use signatures in Outlook 2010

ANGEL 7.3 Student Quickstart Guide

Microsoft Expression Web Quickstart Guide

Implementing Mission Control in Microsoft Outlook 2010

Page Create and Manage a Presentation 1.1 Create a Presentation Pages Where Covered

Table of Contents. Part I Welcome. Part II Introduction. Part III Getting Started. Part IV The User Interface. Part V Quick Start Tutorials

InTime API - Exempel kod

Produced by Flinders University Centre for Educational ICT. PivotTables Excel 2010

Windows 8.1 Tips and Tricks

MICROSOFT OUTLOOK 2011 READ, SEARCH AND PRINT S

Diagnostisera problem med utskriftskvaliteten

PowerPoint 2013 Basics of Creating a PowerPoint Presentation

Excel basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Tanden Care Provider Interfaces ValidateClaim v3

Transcription:

WINDOWS PRESENTATION FOUNDATION LEKTION 4 Mahmud Al Hakim mahmud@alhakim.se www.alhakim.se COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 1 AGENDA Statusbar Hyperlänkar WebBrowser TabControl Ribbon ListBox Data Template Resource Dictionary Style COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 2 1

STATUSBAR <StatusBar VerticalAlignment="Bottom" Background="Beige"> <StatusBarItem> <TextBlock>Copyright 2015 Mahmud Al Hakim</TextBlock> </StatusBarItem> </StatusBar> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 3 HYPERLÄNKAR <TextBlock>Copyright 2016 Mahmud Al Hakim <Hyperlink NavigateUri="http://webacademy.se" RequestNavigate="Hyperlink_RequestNavigate"> www.webacademy.se </Hyperlink> </TextBlock> private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e) { Process.Start(e.Uri.AbsoluteUri); } COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 4 2

WEBBROWSER <Grid> <WebBrowser Name="MahmudBrowser" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Loaded="MainBrowser_Loaded"/> </Grid> private void MainBrowser_Loaded(object sender, RoutedEventArgs e) { ((WebBrowser)sender).Navigate("http://alhakim.se"); } COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 5 TABCONTROL <TabControl> <TabItem Header="Flik 1">Detta är innehållet i flik 1</TabItem> <TabItem Header="Flik 2">Detta är innehållet i flik 2</TabItem> <TabItem Header="Flik 3">Detta är innehållet i flik 3</TabItem> </TabControl> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 6 3

RIBBON Tips! http://www.c-sharpcorner.com/uploadfile/0b73e1/ribbon-control-in-wpf-4-5/ COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 7 STEG 1 LÄGG TILL EN REFERENS COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 8 4

STEG 2 LÄGG TILL EN NAMNRYMD <RibbonWindow x:class="ribbonwin.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ribbonwin="clr-namespace:system.windows.controls;assembly=system.windows.controls.ribbon" Title="Ribbon" > COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 9 STEG 3 FÖRBERED EN PLATS TILL RIBBON <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition/> </Grid.RowDefinitions> </Grid> <Ribbon x:name="ribbonwin" SelectedIndex="0" > COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 10 5

HELPPANECONTENT <!-- Help Pane, located at the right-hand side --> <Ribbon.HelpPaneContent> <RibbonButton SmallImageSource="Images\help.png" /> </Ribbon.HelpPaneContent> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 11 QUICKACCESSTOOLBAR <!-- Quick Access Toolbar - located at the upper-left corner --> <Ribbon.QuickAccessToolBar> <RibbonQuickAccessToolBar> <RibbonButton x:name ="Save" SmallImageSource="Images\save.png" /> <RibbonSplitButton x:name ="Undo" SmallImageSource="Images\undo.png" > <RibbonSplitMenuItem Header="Undo 1" /> </RibbonSplitButton> <RibbonSplitButton x:name="redo" SmallImageSource="Images\redo.png" > <RibbonSplitMenuItem Header="Redo 1" /> </RibbonSplitButton> </RibbonQuickAccessToolBar> </Ribbon.QuickAccessToolBar> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 12 6

APPLICATIONMENU <!-- Application Menu, located at the left-hand side (down arrow) --> <Ribbon.ApplicationMenu> <RibbonApplicationMenu KeyTip="F"> <RibbonApplicationMenuItem Header="Options" ImageSource="Images\options.png" /> <RibbonApplicationMenuItem Header="Exit" ImageSource="Images\quit.png" /> </RibbonApplicationMenu> </Ribbon.ApplicationMenu> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 13 RIBBONTAB OCH RIBBONGROUP <!-- Ribbon Tab #1: Home --> <RibbonTab Header="Home" KeyTip="H" > <!-- Home group--> <RibbonGroup x:name="clipboardgroup" Header="Home"> <RibbonMenuButton LargeImageSource="Images\paste.png" Label="Paste" KeyTip="V"> <RibbonMenuItem ImageSource="Images\paste.png" Header="Keep Text Only" KeyTip="T"/> <RibbonMenuItem ImageSource="Images\paste.png" Header="Paste Special..." KeyTip="S"/> </RibbonMenuButton> <RibbonButton SmallImageSource="Images\cut.png" Label="Cut" KeyTip="X" /> <RibbonButton SmallImageSource="Images\copy.png" Label="Copy" KeyTip="C" /> <RibbonButton SmallImageSource="Images\format_painter.png" Label="Format" KeyTip="F" /> </RibbonGroup> </RibbonTab> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 14 7

FLERA FLIKAR <!-- Ribbon Tab #2: Launch --> <RibbonTab Header="Insert" KeyTip="I"> </RibbonTab> <!-- Ribbon Tab #2: Launch --> <RibbonTab Header="PageLayout" KeyTip="L"> </RibbonTab> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 15 LISTBOX COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 16 8

KLASSEN PERSON public class Person { public string Name { get; set; } public string Epost { get; set; } public static List<Person> GetPersoner() { var personer = new List<Person>(); personer.add(new Person() { Name = "Mahmud", Epost="mahmud@alhakim.se" }); personer.add(new Person() { Name = "Kalle", Epost="kalle@hotmail.se" }); return personer; } } COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 17 EN ENKEL LISTBOX ItemsSource Gets or sets a collection used to generate the content of the System.Windows.Controls.ItemsControl <ListBox Name="Lista" ItemsSource="{Binding}" FontSize="30" > </ListBox> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 18 9

DATAKONTEXT public MainWindow() { InitializeComponent(); DataContext = Person.GetPersoner(); } COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 19 NÅGOT SAKNAS! ToString() anropas och kan givetvis overridas! Men det finns ett bättre sätt med DataTemplate COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 20 10

DATATEMPLATE <ListBox Name="Lista" ItemsSource="{Binding}" FontSize="30" > <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" Margin="2"> <TextBlock Text="Namn:" Margin="2" /> <TextBlock Text="{Binding Name}" Margin="2" /> <TextBlock Text=", E-post:" Margin="2" /> <TextBlock Text="{Binding Epost}" Margin="2" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 21 ARBETA MED RESURSER (RESOURCE DICTIONARY) <Window.Resources> <SolidColorBrush x:key="mycolor" Color="#FFFF1111" /> </Window.Resources> <Grid> <StackPanel Orientation="Vertical"> <TextBlock Text="Ett" Foreground="{StaticResource mycolor}" /> <TextBlock Text="Två" /> <TextBlock Text="Tre" Foreground="{StaticResource mycolor}" /> </StackPanel> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 22 11

SKAPA RESURSER I SEPARATA FILER COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 23 EN RESURSFIL (T.EX. COLORS.XAML) COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 24 12

ANGE RESOURCE DICTIONARY I APP.XAML COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 25 STILMALLAR STATISKA RESURSER <Window.Resources> <Style TargetType="TextBlock" x:key="mahmudstyle"> <Setter Property="FontSize" Value="100" /> </Style> </Window.Resources> <Grid> <TextBlock Style="{StaticResource MahmudStyle}"> Lite text och annat smått och gott. </TextBlock> Stilen har en nyckel Koppling sker med hjälp av en StaticResource </Grid> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 26 13

STILMALLAR ARV <Window.Resources> <Style TargetType="TextBlock" x:key="mahmudstyle"> <Setter Property="FontSize" Value="50" /> </Style> <Style TargetType="TextBlock" x:key="alhakimstyle" BasedOn="{StaticResource MahmudStyle}"> <Setter Property="Foreground" Value="Green" /> </Style> </Window.Resources> <Grid> <TextBlock Style="{StaticResource AlhakimStyle}"> Lite text och annat smått och gott. AlhakimStyle äver från (BasedOn) MahmudStyle </TextBlock> </Grid> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 27 AUTOMATISKA STILMALLAR <Window.Resources> <Style TargetType="TextBlock"> </Style> </Window.Resources> <Setter Property="FontSize" Value="20" /> <Setter Property="Foreground" Value="Blue" /> <Setter Property="HorizontalAlignment" Value="Left" /> <Grid> <TextBlock>Lite text och annat smått och gott. </TextBlock> <TextBlock>Lite text och annat smått och gott. </TextBlock> </Grid> En stilmall som kopplas till alla TextBlock i detta fönster Ingen nyckel behövs! COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 28 14

LOKALA STILMALLAR <Window.Resources> <Style TargetType="TextBlock"> </Style> </Window.Resources> <Setter Property="FontSize" Value="20" /> <Setter Property="Foreground" Value="Blue" /> <Setter Property="HorizontalAlignment" Value="Left" /> <Grid> <StackPanel Orientation="Vertical"> </StackPanel> <TextBlock Text="Ett" /> <TextBlock Text="Två" FontSize="30" /> <TextBlock Text="Tre" /> En stilmall som enbart gäller detta fönster. OBS! Inline formatering har högre prioritet </Grid> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 29 GLOBALA STILMALLAR I APP.XAML <Application.Resources> <Style TargetType="TextBlock" x:key="mahmudstyle"> <Setter Property="FontSize" Value="50" /> </Style> <Style TargetType="TextBlock" x:key="alhakimstyle" BasedOn="{StaticResource MahmudStyle}"> <Setter Property="Foreground" Value="Green" /> </Style> </Application.Resources> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 30 15

EXTERNA STILMALLAR FLYTTA STILAR TILL EN NY FIL (T.EX. STYLES.XAML) COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 31 UPPDATERA APP.XAML <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/Colors.xaml" /> <ResourceDictionary Source="Resources/Styles.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 32 16

ÖVNING Skapa en enkel Timer enligt bilden nedan. Skapa en extern stilmall (separat fil) som formaterar alla knappar (valfritt utseende). COPYRIGHT 2015 MAHMUD AL HAKIM WWW.WEBACADEMY.SE 33 17