Time of Update: 2018-12-05
1、把Win32的按鈕添加到WPF視窗中1)添加如下的using指令using System.Windows.Interop;using System.Runtime.InteropServices;2)建立Win32ButtonHost類 public class Win32ButtonHost : HwndHost { IntPtr hwndHost = IntPtr.Zero; IntPtr hwndButton =
Time of Update: 2018-12-05
FlagsAttribute屬性在enum中的應用 我看了Effective C#一書中的Item 8 : Ensure That 0 Is a Valid State for ValueTypes時提到了Flags屬性在enum中的應用,於是就查了一下資料,寫了一點關於這個的體會 .Net C#中枚舉的聲明格式如下所示:[attributes] [modifiers] enum identifier [:base-type] {enumerator-list}
Time of Update: 2018-12-05
Regsvr32.exe 用法RegSvr32.exe 具有以下命令列選項:Regsvr32 [/u] [/n] [/i[:cmdline]] dllname/u– 取消註冊伺服器 /i – 調用 DllInstall,為其傳遞一個可選 [cmdline];當與 /u 一起使用時,可調用 dll 卸載/n – 不調用 DllRegisterServer;此選項必須與 /i 一起使用 /s – 靜默;不顯示任何訊息框(在 Windows XP和 Windows Vista 中附加)在使用
Time of Update: 2018-12-05
<Grid> <Canvas x:Name="LayoutRoot"> <Image Cursor="Hand" MouseLeftButtonDown="imgLogo1_MouseLeftButtonDown" MouseEnter="imgLogo1_MouseEnter" MouseLeave="imgLogo1_MouseLeave" Canvas.ZIndex="1"
Time of Update: 2018-12-05
如是系統的結構圖:這個樣本是模仿計算機的MVVM模式的精簡版,非常簡單。這篇文章就開門見山了,有關MVVM的理論部分,請參考MVVM設計模式1、App中的代碼: public App() { CalculatorView view = new CalculatorView(); view.DataContext = new CalculatorViewModel(); view.Show();
Time of Update: 2018-12-05
Binding是Wpf的核心內容之一1、下面是Binding基礎的一個例子。XAML: <Grid> <TextBox x:Name="myTextBox" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top" Width="200"/> <Button Height="23" HorizontalAlignment="Left" Margin="38,89,0
Time of Update: 2018-12-05
為WPF添加Windows表單控制項1、通過XAML實現 1)添加WindowsFormIntegration.dll引用 引用命名空間 xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"2)通過XAML來實現 <Grid x:Name="myGrid"> <Grid.RowDefinitions>
Time of Update: 2018-12-05
WPF的小樣本1、<Window x:Class="GadgetWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" AllowsTransparency="True" WindowStyle="None" Background="
Time of Update: 2018-12-05
1、怎樣在WPF中使用Windows表單控制項(如水晶報表)我們可以使用WindowsFormsHost元素在WPF中載入一個Windows Forms控制項,下面的這個例子展示了如何載入一個CrystalReportViewer元素:<Window x:Class="ForumProjects.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Time of Update: 2018-12-05
這篇文章僅僅是寫如何找BUG,只是列出本人這些年來用.net編寫程式過程中尋找BUG的一些方式方法,歡迎大夥踴躍跟帖,你的輕描淡寫,或許能解除某些人心中由來已久的迷團。寫程式有了BUG是經常的事情,只是它們形式多樣,有的直接能看到,有的隱藏比較深,從表象看幾乎不能看出來,只有特定的場合能誘發、啟用這種BUG,我們以前經常聽到別人講要如何正常化寫代碼,注意層次,藕合度,函數的行數等等,這些良言佳句的確能減少我們出錯的幾率和排錯的時間,但人不是機器,出錯總是會有的,出了錯,如何及時有效地把它揪出來予
Time of Update: 2018-12-05
MediaElement的暫停,播放功能。<UserControl x:Class="Control_Test.MediaElement" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <UserControl.Resources>
Time of Update: 2018-12-05
屬性是我們再熟悉不過的了,那麼究竟相依性屬性怎麼寫呢?相依性屬性和屬性到底有什麼區別和聯絡呢?其實相依性屬性的實現很簡單,只要做以下步驟就可以實現: 第一步: 讓所在類型繼承自 DependencyObject基類,在WPF中,我們仔細觀察架構的類圖結構,你會發現幾乎所有的 WPF 控制項都間接繼承自DependencyObject類型。 第二步:使用 public static 聲明一個 DependencyProperty的變數,該變數才是真正的相依性屬性
Time of Update: 2018-12-05
WPF沒有像ASP.NET提供一個RadioButtonList的控制項。幸運的是,我們可以利用WPF樣式和模板的強大功能,用純粹的XAML代碼實現這個功能<Window x:Class="ControlTest2.ListBoxTest2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Time of Update: 2018-12-05
【原文:http://www.cnblogs.com/chenxizhang/】大家是否還記得在Windows Forms程式中如何?splashScreen嗎?我們一般都會使用Microsoft.VisualBasic.dll中提供的那個WindowsFormsApplicationBase類型,它有一個所謂的splashscreen屬性,可以指定為一個表單的。那麼,同樣的需求在WPF中如何?呢?這要從兩頭來說,從簡單來說,它實在是簡單了。事實上,這是.NET Framework 3.5sp1
Time of Update: 2018-12-05
在日常的開發中,往往在表單被提交之前需要加上驗證(驗證日期格式是否正確,驗證某個input是否為空白…),首先想到的就是 onsubmit事件,在一個submit類型按鈕點擊時,首先觸發的就是form的onsubmit()事件。這時,我們就可以寫上自己的驗證。代碼如下:<form action="1.asp" method="post" name="form1" onsubmit=“alert(‘執行了onsubmit事件’);return true;”>
Time of Update: 2018-12-05
1、WPF 獲得DataTemplate中的控制項, 下面這個樣本是從ListBox中獲得ListBoxItem模板的控制項資訊。前台代碼: <!--獲得模板中的控制項--> <ListBox Margin="12,32,0,0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" Name="listBox1" SelectedIndex="0" Height="186"
Time of Update: 2018-12-05
使用WPF做的一個模板頁樣本下面是專案檔圖:關鍵代碼如下:<Page x:Class="WpfMasterPageTes.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" ShowsNavigationUI="False">
Time of Update: 2018-12-05
LINQ查詢的結果是一個IEnumberable<T>類型對象,而IEnumberable<T>類型對象有派生自IEnumberable,所以它可以作為清單控制項的ItemsSource來使用.我建立了一個Sutdent類: public class Student { public int ID{ get; set;} public string Name { get; set; } public string
Time of Update: 2018-12-05
今天從資料庫中讀記錄,不知道怎麼回事,總是出現換行,在網上找了很多方法,大體上就是用Replace替換chr(10),chr(13)之類 的,結果還是沒有解決問題,即使在資料庫中把換行處的空格刪掉仍然顯示有換行,真的是無語了。最後在從資料庫中讀取記錄的時候就進行替換:(LTRIM(replace(replace(photo_title,char(10),''),char(13),''))) as
Time of Update: 2018-12-05
1、附加屬性:一個屬性原來不屬於某個對象,但由於某種需求而被後來附加上去。附加屬性的本質是相依性屬性。2、附加屬性作用:將屬性與資料類型解耦,讓資料類型的設計的更加靈活。3、VS 2008中,相依性屬性的snippet是propdp,附加屬性的snippet是propa,屬性的snippet是prop。4、舉個例子,Human,School。Human中的一個人,他如果在學校裡,就會有成績等;如果在公司裡,他就有部門等。此時的成績和部門就是附加屬性。代碼如下:School類 class