You are on page 1of 20

Bi 2 CC IU KHIN (CONTROL) C BN CA WPF

Trong lp trnh giao din ngi dng, iu kin (Control) l cc nhn t quan trng cu thnh nn giao din ngi dng, cho php h giao tip vi ng dng. Control c th c hiu mt cch n gin l cc phn t trn mt ca s nh cc nhn (Label), hp son tho (TextBox), nt bm (Button), hp danh sch (ListBox, ComboBox),.. hin th cc thng tin ti ngi dng v cho php ngi dng nhp thng tin cn thit cho chng trnh. Phn ny gii thiu cch to lp v s dng cc Control c bn nht ca ca s xy dng bng cng ngh WPF.

1. Tng quan v to lp cc iu khin vi WPF


im khc bit c bn gia m lnh to giao din da trn WPF so vi phng php c l ng dng WPF s dng cc c t XAML (ngoi vic s dng m lnh C# hay VB.Net) nh ngha giao din, trong khi phng php c phi s dng trc tip m lnh ca C# hay VB.Net nh ngha giao din. V d, xy dng giao din ca s n gin nh Hnh 2.1 di y.

Label

TextBox

Button

Hnh 2.1 Mt v d v ca s vi cc control n gin


on m trnh bng XAML:
<Grid> <Label Height="30" HorizontalAlignment="Left" Margin="10,15,0,0" Name="label1" VerticalAlignment="Top" Width="60">H m:</Label>

<Label Height="30" HorizontalAlignment="Left" Margin="10,50,0,0" Name="label2" VerticalAlignment="Top" Width="60">Tn:</Label>

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

<TextBox Height="30" Margin="80,17,30,0" Name="textBox1" VerticalAlignment="Top" />

<TextBox Height="30" Margin="80,52,30,0" Name="textBox2" VerticalAlignment="Top" />

<Button Height="35" HorizontalAlignment="Left" Margin="16,0,0,27" Name="button1" VerticalAlignment="Bottom" Width="110">Xem thng tin</Button>

<Button Height="35" HorizontalAlignment="Right" Margin="0,0,24,27" Name="button2" VerticalAlignment="Bottom" Width="110">Nhp li</Button> </Grid>

on m trnh bng C#:


// To nhn H m this.label1 = new System.Windows.Forms.Label(); this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(17, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(48, 13); this.label1.TabIndex = 0; this.label1.Text = "H m:"; //To nhn Tn this.label2 = new System.Windows.Forms.Label();

this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(17, 50); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(29, 13); this.label2.TabIndex = 0; this.label2.Text = "Tn:"; //To TextBox nhp H m this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1.Location = new System.Drawing.Point(100, 16); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(160, 20); this.textBox1.TabIndex = 1; //To TextBox nhp Tn

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox2.Location = new System.Drawing.Point(100, 50); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(160, 20); this.textBox2.TabIndex = 1; // To nt bm Xem thng tin this.button1 = new System.Windows.Forms.Button(); this.button1.Location = new System.Drawing.Point(20, 114); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(99, 38); this.button1.TabIndex = 2; this.button1.Text = "Xem thng tin"; this.button1.UseVisualStyleBackColor = true; //To nt bm nhp li this.button2 = new System.Windows.Forms.Button(); this.button2.Location = new System.Drawing.Point(161, 114); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(99, 38); this.button2.TabIndex = 2; this.button2.Text = "Nhp li"; this.button2.UseVisualStyleBackColor = true;

Nh vy, iu chng ta cn l tm hiu cc th XAML m t cc Control cn thit. Tuy nhin bn khng cn phi lo lng nu nh cha quen vi cc m lnh XAML (da trn XML) ny v b cng c Visual Studio.Net 2008 h tr thit k giao din trc quan v t ng sinh m XAML tng ng.

2. Cc iu khin c bn trong WPF


Chng ta s tm hiu chi tit mt s iu khin c bn ca ca s: Label: Nhn. TextBox: Hp son tho. Button: Nt bm. CheckBox: Hp chn. RadioButton: Hp chn radio (ch c php chn 1 mc trong mi nhm). ListBox: Hp danh sch

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

ComboBox: Hp danh sch th xung..

1.1

LABEL - Nhn

Nhn (Label) l cc iu kin hin th cc vn bn tnh, thng c s dng lm nhn cho cc control khc nh Textbox, ListBox, ComboBox,.

Label

Label

Hnh 2.2 Minh ha v label


Cc Label uc m t bng on m XAML sau:
<Grid> <Label Height="30" HorizontalAlignment="Left" Margin="10,15,0,0" Name="label1" VerticalAlignment="Top" Width="60">H m:</Label> </Grid>

Nhn uc bt u <Label> v kt thc l </Label>, ni dung ca nhn l on vn bn t gia cp th ny. Trong v d ny H m: l ni dung ca nhn. Bn trong th <Label> c rt nhiu c tnh m t v th, trong :
Height="30 : cao ca khung nhn l 30px HorizontalAlignment="Left" : Nhn c cn tri trong ca s Margin="10,15,0,0" : c 4 gi tr l Left,Top,Right,Bottom Name="label1" : Tn ca nhn l lablel1 VerticalAlignment="Top" :Nhn c cn theo nh ca ca s. Width="60": Chiu rng ca nhn l 60px

Trn y l mt s c tnh c bn ca nhn, ngoi ra cn c nhiu c tnh khc p dng cho nhn nh mu nn, mu ch,.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

1.2

TextBox Hp son tho

Hp son tho (TextBox) l control cho php ngi dng nhp d liu dng vn bn.

TextBox

TextBox

Hnh 2.3 Minh ha v TextBox


Di y l on m XAML ca hp son tho
<Grid> <TextBox Height="30" Margin="80,17,30,0" Name="textBox1" VerticalAlignment="Top" /> Hp son tho </TextBox>

<TextBox Height="30" Margin="80,52,30,0" Name="textBox2" VerticalAlignment="Top" /> </Grid>

Hp son tho c to nn bi th <TextBox/>. Nu mun thit lp sn ni dung mc nh cho hp son tho, ta t ni dung ny vo gia cp th <TextBox/> Ni dung </TextBox>. Nu khng mun t gi tr mc nh th khng cn th ng </TextBox>. Th <TextBox/> cng c nhiu c tnh, trong :
Margin="80,17,30,0": Cch l tri 80, nh ca s 17, cnh phi 30 Name="textBox1": Tn ca hp son tho l textBox1 VerticalAlignment="Top": Cn theo nh ca s

c im ca hp son tho vi cc c tnh trn l khi ngi dng co dn, thay i kch thc ca s, chiu rng ca hp son tho t ng co dn theo.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

1.3

Button Nt bm

Nt bm (Button) l loi iu khin cho php ngi dng nhn chut chn lnh, khi nhn vo nt bm, n s sinh ra s kin Click v s chy cc lnh gn vi s kin ny.

Button Button

Hnh 2.4 Minh ha v nt bm

Di y l on m sinh ra cc nt bm trn
<Grid> <Button Height="35" HorizontalAlignment="Left" Margin="16,0,0,27" Name="button1" VerticalAlignment="Bottom" Width="110" Click="button1_Click">Xem thng tin</Button> <Button Height="35" HorizontalAlignment="Right" Margin="0,0,24,27" Name="button2" VerticalAlignment="Bottom" Width="110">Nhp li</Button> </Grid>

Nt bm c bt u bng th <Button> v kt thc bng th </Button>. Nhn ca nt bm c t trong cp th <Button> Nhn nt bm </Button>. Nt bm c nhiu c tnh, trong : Height="35": Chiu cao nt bm l 35 Width="110": Chiu rng l 110 HorizontalAlignment="Left": Cn theo l tri VerticalAlignment="Bottom": Cn theo y ca s Margin="16,0,0,27": Cch l tri 16, cch y 27 Name="button1": Tn nt bm l button1

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

Click="button1_Click": Khi nhn chut vo nt s kch hot phng thc

button1_Click() Vi d v on m lnh gn vi ca s cha cc iu khin trn:


namespace WpfControlSample1 { public partial class Window1 : Window { public Window1() { InitializeComponent(); }

private void button1_Click(object sender, RoutedEventArgs e) { String strHoTen; strHoTen = textBox1.Text + " " + textBox2.Text; MessageBox.Show("Xin cho: " + strHoTen); } } }

1.4

Radio Button v CheckBox

Radio Button v CheckBox u l iu khin dng hp chn. Tuy nhin, im khc bit c bn gia hai loi iu khin ny l: Radio Button: l hp chn theo nhm, ngha l cc hp trong cng mt nhm s loi tr nhau, ti mt thi im ngi dng ch c chn mt trong cc mc. Vi d nh hp chn gii tnh, ta phi s dng radio v ti mt thi im ch cho php chn Nam hoc N CheckBox: l hp chn m ngi dng c th chn mt hoc nhiu mc cng mt lc. Vi d nh mc chn Ngoi ng, cho php ngi dng chn ng thi nhiu mc.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

Radio Button CheckBox

Hnh 2.5 Minh ha v hp chn Radio v CheckBox


Di y l on m to Radio Button v CheckBox.
<Grid>

<Label Height="30" HorizontalAlignment="Left" Margin="10,94,0,0" Name="label3" VerticalAlignment="Top" Width="60">Gii tnh:</Label>

<RadioButton Height="22" Margin="80,99,0,0" Name="radioButton1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="79" GroupName="GioiTinh" IsChecked="True">Nam</RadioButton>

<RadioButton Height="22" HorizontalAlignment="Right" Margin="0,99,30,0" Name="radioButton2" VerticalAlignment="Top" Width="79" GroupName="GioiTinh">N</RadioButton>

<Label HorizontalAlignment="Left" Margin="10,127,0,105" Name="label4" Width="69">Ngoi ng:</Label>

<CheckBox Margin="84,0,119,110" Name="checkBox1" Height="20" VerticalAlignment="Bottom" IsChecked="True">Ting Anh</CheckBox>

<CheckBox HorizontalAlignment="Right" Margin="0,0,24,110" Name="checkBox2" Width="85" Height="20" VerticalAlignment="Bottom">Ting Trung</CheckBox> </Grid>

Radio Button c to bi th <RadioButton> v kt thc bi</RadioButton>, gia cp th ny l nhn ca Radio Button <RadioButton> Nhn </RadioButton>.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

CheckBox c to bi th <CheckBox > v kt thc bi</CheckBox>, gia cp th ny l nhn ca CheckBox <CheckBox> Nhn </CheckBox>. C hai th ny u c c tnh IsChecked="True" hoc IsChecked="False". Mc no c thuc tnh ny s c t ng chn khi ca s bt u hin th. i vi Radio Button, v l hp chn loi tr, nu trong mt ca s c nhiu nhm Radio Button khc nhau th cc Radio Button ca mi nhm uc phn bit bi c tnh GroupName="TenNhom". V d, trn cng mt ca s c hai Radio Button chn Gii tnh (Nam; N) v ba Radio Button khc chn ngh nghip (Kinh doanh; K Thut; Marketing) th cc Radio Button Nam, Nu phi c cng GroupName vi nhau, ba Radio Button Kinh doanh, Ky Thuat, Marketting phi c cng GroupName v khc vi GroupName ca nhm gii tnh. on m lnh minh ha kim tra mc chn Radio
private void button1_Click(object sender, RoutedEventArgs e) { String strMessage, strHoTen, strTitle, strNgoaiNgu=""; strHoTen = textBox1.Text + " " + textBox2.Text;

if (radioButton1.IsChecked==true) strTitle = "Mr."; else strTitle = "Miss/Mrs."; strMessage = "Xin cho: " + strTitle + " " + strHoTen; MessageBox.Show(strMessage); }

on m lnh minh ha kim tra mc chn CheckBox


private void button1_Click(object sender, RoutedEventArgs e) { String strMessage, strNgoaiNgu="";

if (checkBox1.IsChecked == true) { strNgoaiNgu = "Ting Anh"; } if (checkBox2.IsChecked == true) { strNgoaiNgu = (strNgoaiNgu.Length==0) ? "Ting Trung": (strNgoaiNgu+ " v Ting Trung");

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

} strMessage = "Ngoi ng: " + strNgoaiNgu; MessageBox.Show(strMessage); }

1.5 ListBox - Hp danh sch


Hp danh sch (ListBox) v l iu khin hin th mt danh sch cc mc theo tng dng v cho php ngi dng chn mt hay nhiu phn t ca danh sch. V d v hp danh sch chn Qu qun:

ListBox

Hnh 2.6 Minh ha v hp chn ListBox


Di y l on m to ListBox
<Grid>

<Label Height="30" HorizontalAlignment="Left" Margin="10,0,0,126" Name="label5" VerticalAlignment="Bottom" Width="69">Qu qun:</Label>

<ListBox Height="68" Margin="80,0,33,77" Name="listBox1" VerticalAlignment="Bottom" SelectedIndex="0"> <ListBoxItem>H ni</ListBoxItem> <ListBoxItem>TP. H Ch Minh</ListBoxItem> <ListBoxItem>Hi Phng</ListBoxItem>

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

10

<ListBoxItem> Nng</ListBoxItem> </ListBox> </Grid>

ListBox c to bi th <ListBox> v kt thc bng th ng </ListBox> . Mi phn t ca danh sch nm trong cp th <ListBoxItem> Nhn </ListBoxItem> lng bn trong cp th trn. c tnh SelectedIndex="k" yu cu t ng chn phn th th n trong danh sch khi m ca s. Phn t u tin ca danh sch c gi tr l 0, phn t cui cng l n-1. Nu mun khi m ca s khng chn phn t no th t gi tr k bng -1.

on m lnh ly mc chn t ListBox


private void button1_Click(object sender, RoutedEventArgs e) { String strMessage; if (listBox1.SelectedIndex >= 0)//Nu c mt mc trong danh sch c chn { strMessage = Qu Qun: " + listBox1.Text; } MessageBox.Show(strMessage); }

1.6 ComboBox - hp danh sch th xung


Hp danh sch th xung (ComboBox) l cc iu khin hin th mt danh sch theo tng dng cho ngi dng chn. Tuy nhin, khc vi ListBox, ComboBox gn gng hn bi v n ch hin th 1 dng v khi nhn vo biu tng tam gic bn cnh th danh sch mi c m ra. Combox ch cho php chn 1 dng ti 1 thi im. V d v hp danh sch th xung chn Qu qun:

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

11

ComboBox

Hnh 2.7 Minh ha v hp chn ComboBox


Di y l on m to ComboBox
<Grid>

<Label Height="30" HorizontalAlignment="Left" Margin="10,0,0,126" Name="label5" VerticalAlignment="Bottom" Width="69">Qu qun:</Label>

<ComboBox Height="26" Margin="84,0,27,126" Name="comboBox1" VerticalAlignment="Bottom" SelectedIndex="0"> <ComboBoxItem>H ni</ComboBoxItem> <ComboBoxItem>TP. H Ch Minh</ComboBoxItem> <ComboBoxItem>Hi Phng</ComboBoxItem> <ComboBoxItem> Nng</ComboBoxItem> </ComboBox> </Grid>

ComboBox c to bi th <ComboBox> v kt thc bng th ng </ComboBox> . Mi phn t ca danh sch nm trong cp th <ComboBoxItem> Nhn </ComboBoxItem> Lng bn trong cp th trn.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

12

c tnh SelectedIndex="k" yu cu t ng chn phn th th n trong danh sch khi m ca s. Phn t u tin ca danh sch c gi tr l 0, phn t cui cng l n-1. Nu mun khi m ca s khng chn phn t no th t gi tr k bng -1. on m lnh ly mc chn t ComboBox
private void button1_Click(object sender, RoutedEventArgs e) { String strMessage; if (comboBox1.SelectedIndex >= 0)//Nu c mt mc trong danh sch c chn { strMessage = Qu Qun: " + comboBox1.Text; } MessageBox.Show(strMessage); }

3. V d xy dng cc control trong WPF


Yu cu: Vit chng trnh hin th ca s nh sau

Khi nhn Xem thng tin, nu chn Nam th hin li cho Xin cho Mr. Barack Obama, nu chn N th hin li cho Xin cho Miss/Mrs. Barack Obama, nh sau:

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

13

Nu chn Nhp li, a trng thi cc control trn ca s v trng thi ban u. Cc bc thc hin nh sau:

3.1 To ng dng WPF

y, ta ch chn .Net Framework 3.5. Giao din thit k ng dng:

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

14

3.2 M XAML ca giao din


M file Window1.xaml tng ng vi file code Window1.xaml.cs.
<Window x:Class="WpfControlSample1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="V d Control - WPF" Height="352" Width="300"> <Grid> <Label Height="30" HorizontalAlignment="Left" Margin="10,15,0,0" Name="label1" VerticalAlignment="Top" Width="60" Focusable="False">H m:</Label> <Label Height="30" HorizontalAlignment="Left" Margin="10,50,0,0" Name="label2" VerticalAlignment="Top" Width="60">Tn:</Label> <TextBox Height="30" Margin="80,17,30,0" Name="textBox1" VerticalAlignment="Top">Hp son tho</TextBox> <TextBox Height="30" Margin="80,52,30,0" Name="textBox2" VerticalAlignment="Top" />

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

15

<Button Height="35" HorizontalAlignment="Left" Margin="16,0,0,27" Name="button1" VerticalAlignment="Bottom" Width="110" Click="button1_Click">Xem thng tin</Button> <Button Height="35" HorizontalAlignment="Right" Margin="0,0,24,27" Name="button2" VerticalAlignment="Bottom" Width="110" Click="button2_Click">Nhp li</Button> <Label Height="30" HorizontalAlignment="Left" Margin="10,94,0,0" Name="label3" VerticalAlignment="Top" Width="60">Gii tnh:</Label> <RadioButton Height="22" Margin="80,99,0,0" Name="radioButton1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="79" GroupName="GioiTinh" IsChecked="True">Nam</RadioButton> <RadioButton Height="22" HorizontalAlignment="Right" Margin="0,99,30,0" Name="radioButton2" VerticalAlignment="Top" Width="79" GroupName="GioiTinh">N</RadioButton> <Label HorizontalAlignment="Left" Margin="10,127,0,154" Name="label4" Width="69">Ngoi ng:</Label> <CheckBox Margin="84,132,119,0" Name="checkBox1" Height="20" VerticalAlignment="Top" IsChecked="True">Ting Anh</CheckBox> <CheckBox HorizontalAlignment="Right" Margin="0,132,24,0" Name="checkBox2" Width="85" Height="20" VerticalAlignment="Top">Ting Trung</CheckBox> <Label Height="30" HorizontalAlignment="Left" Margin="10,0,0,126" Name="label5" VerticalAlignment="Bottom" Width="69">Qu qun:</Label> <ComboBox Height="26" Margin="84,0,27,126" Name="comboBox1" VerticalAlignment="Bottom" SelectedIndex="0"> <ComboBoxItem>H ni</ComboBoxItem> <ComboBoxItem>TP. H Ch Minh</ComboBoxItem> <ComboBoxItem>Hi Phng</ComboBoxItem> <ComboBoxItem> Nng</ComboBoxItem> </ComboBox> </Grid> </Window>

Gn tn phng thc button1_Click x l s kin Click cho nt bm button1 ny, khi nhn chut vo nt Xem thng tin th phng thc button1_Click s c thc thi.
<Button Height="35" HorizontalAlignment="Left" Margin="16,0,0,27" Name="button1" VerticalAlignment="Bottom" Width="110" Click="button1_Click">Xem thng tin</Button>

Gn tn phng thc button2_Click x l s kin Click cho nt bm button2 ny, khi nhn chut vo nt Nhp li th phng thc button2_Click s c thc thi.
<Button Height="35" HorizontalAlignment="Right" Margin="0,0,24,27" Name="button2" VerticalAlignment="Bottom" Width="110" Click="button2_Click">Nhp li</Button>

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

16

3.3 M lnh C# x l cc s kin nhn nt


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;

namespace WpfControlSample1 { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); }

private void button1_Click(object sender, RoutedEventArgs e) { String strMessage, strHoTen, strTitle, strNgoaiNgu=""; strHoTen = textBox1.Text + " " + textBox2.Text; if (radioButton1.IsChecked==true) strTitle = "Mr."; else strTitle = "Miss/Mrs."; strMessage = "Xin cho: " + strTitle + " " + strHoTen;

if (checkBox1.IsChecked == true) {

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

17

strNgoaiNgu = "Ting Anh"; } if (checkBox2.IsChecked == true) { strNgoaiNgu = (strNgoaiNgu.Length==0) ? "Ting Trung": (strNgoaiNgu+" v Ting Trung"); } strMessage += "\n Ngoi ng: " + strNgoaiNgu; if (comboBox1.SelectedIndex >= 0)//Nu c mt mc trong danh sch c chn { strMessage += "\n Qu Qun: " + comboBox1.Text; } MessageBox.Show(strMessage); }

private void button2_Click(object sender, RoutedEventArgs e) { textBox1.Text = ""; textBox2.Text = ""; radioButton1.IsChecked = true; radioButton2.IsChecked = false; checkBox1.IsChecked = false; checkBox2.IsChecked = false; comboBox1.SelectedIndex = 0; }

} }

F5 chy ng dng. Ta s thu c kt qu tng t nh yu cu.

Cu hi n tp
1. Control l g?

Control phn t trn mt ca s nh cc nhn (Label), hp son tho (TextBox), nt bm (Button), hp danh sch (ListBox, ComboBox),.. hin th cc thng tin ti ngi dng v cho php ngi dng nhp thng tin cn thit cho chng trnh. 2. Cc control trong WPF c nh bng? A. B. c t XAML M trnh (C# hoc Visual Basic)

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

18

C. Cu tr li: C 3.

C A v B

Cc control c bn trong WPF bao gm? (chn nhiu) A. B. C. D. Label, TextBox, Button Radio Button, CheckBox, ListBox v ComboBox Grid, WrapPanel C A, B v C

Cu tr li: A v B 4. c php chn ng thi nhiu Radio Button trong cng nhm: A. B. Cu tr li: B 5. c php chn ng thi nhiu CheckBox: A. B. Cu tr li: A 6. Khi dng th <TextBox> to hp son tho, bt buc phi kt thc bng ng Sai ng Sai

th ng </TextBox>: A. B. Cu tr li: B ng Sai

Ti liu tham kho


1. Windows Presentation Foundation, URL: http://msdn.microsoft.com/enus/library/ms754130.aspx. 2. Introducing Windows Presentation Foundation, URL: http://msdn.microsoft.com/enus/library/aa663364.aspx. 3. WPF Architecture, URL: http://msdn.microsoft.com/en-us/library/ms750441.aspx. 4. WPF Tutorial, URL: http://dotnetslackers.com/articles/silverlight/WPFTutorial.aspx.

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

19

5. WPF Tutorials, URL: http://www.wpftutorial.net/. 6. Windows Presentation Foundation Control, http://msdn.microsoft.com/enus/library/ms752069.aspx

Microsoft Vietnam DPE Team | WPF Bi 2: Cc iu khin (Control) c bn ca WPF

20

You might also like