一、不可空資料型別 int datetime boolean
string str1 = "";string s1 = null;
messagebox.show(str1.length.tostring());
//空指標會引發異常
int? i1 = null;
int i2 = 6;
i1 = i2;
int? i3 = null; //error
//int i4 = i3;
int i4 = (int)i3; //ok,但是如果傳入的是null型別,會引發異常
二、常用控制項
1、passwordbox 屬性password,設定預設密碼
2、checkbox 屬性ischecked 預設返回boolean? 可空資料型別,因此可以用 == true方法解決是比較好的
private void checkbox1_checked(object sender, routedeventargs e)}
3、radiobutton groupname屬性 組的名稱
"name
" content="
radiobutton
" height="
16" horizontalalignment="
left
" margin="
111,122,0,0
" name="
radiobutton1
" verticalalignment="
top" />
"name
" content="
radiobutton
" height="
16" horizontalalignment="
left
" margin="
111,144,0,0
" name="
radiobutton2
" verticalalignment="
top" />
"name
" content="
radiobutton
" height="
16" horizontalalignment="
left
" margin="
111,166,0,0
" name="
radiobutton3
" verticalalignment="
top" />
"age
" content="
radiobutton
" height="
16" horizontalalignment="
left
" margin="
269,131,0,0
" name="
radiobutton4
" verticalalignment="
top" />
"age
" content="
radiobutton
" height="
16" horizontalalignment="
left
" margin="
269,153,0,0
" name="
radiobutton5
" verticalalignment="
top" />
4、datepicker 控制項 selecteddate 賦予時間,獲取時間
privatevoid button1_click(object
sender, routedeventargs e)
else
}private
void button2_click(object
sender, routedeventargs e)
5、progressbar 控制項 屬性maximum、minimum、value、isindeterminate(用於不可控因素)
maximum="100"
minimum="0"
value="
10" height="
10" horizontalalignment="
left
" margin="
24,197,0,0
" name="
progressbar1
" verticalalignment="
top" width="
100" />
isindeterminate="
true
" height="
10" horizontalalignment="
left
" margin="
174,197,0,0
" name="
progressbar2
" verticalalignment="
top" width="
100" />
"加血" height="
23" horizontalalignment="
left
" margin="
24,213,0,0
" name="
button3
" verticalalignment="
top" width="
75" click="
button3_click
" />
privatevoid button3_click(object
sender, routedeventargs e)
WPF學習筆記五之MVVM
1.概念 mvvm是model view viewmodel的縮寫形式,它通常被用於wpf或silverlight開發。這三者之間的關係如下圖所示 模型 model model 可以理解為帶有字段,屬性的類。檢視 view view 可以理解為我們所看到的ui。檢視模型 view model vie...
wpf學習筆記
1.選單 普通選單 上下文選單 contextmenu 2.dockpanel 讓元素靠左右上下 3.放入其中的控制項都有新的預設外觀 顯示圖示的方法 button的content中放image 4.多視窗 視窗名字 window title 居中 window windowstartuplocat...
WPF學習筆記
一些定製 使用metrowindow控制項 使用內建樣式 xmlns xmlns x xmlns xmlns x 修改mainwindow.xaml檔案 1.開啟mainwindow.xaml檔案 2.在window標籤中新增屬性 或 3.修改標籤為control metrowindow 如下 xm...