當我們使用MVVM開發模式進行開發時,ViewModel之間的通訊常常是很頭疼的事情,好在MVVM Light提供了Messenger類可以輕鬆的在ViewModel之間傳遞訊息。MessengerMessenger 其他類成員可以通過Register 方法 來建立與Messenger的聯絡,註冊時包含當收到Message的時候要執行的方法。當使用Send方法時,註冊的相關的方法將會被調用。The Messager is a class allowing objects to exchange
RelayCommand : ICommand類A command whose sole purpose is to relay its functionality to otherobjects by invoking delegates. The default return value for the CanExecutemethod is 'true'. This class does not allow you to accept command parameters in
當我們需要操作ListBox中的ScrollerBar的時候我們可以通過VisualTreeHelper來找到。代碼如下:public static childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject{ // Search immediate children first (breadth-first) for (int i = 0;
//合并兩個數組public class Merge { public static int[] Merge (int[]a,int[] b){ int la=a.length; int lb=b.length; int pa=0,pb=0,pc=0; int[] c=new int[la+lb]; while(pa<la&&pb<lb){ if(a[pa]<b[pb]){
文章目錄 問題由來與單一職責原則的區別注意事項 設計模式系列文章設計模式六大原則(1):單一職責原則設計模式六大原則(2):裡氏替換原則設計模式六大原則(3):依賴倒置原則設計模式六大原則(4):介面隔離原則問題由來 類A通過介面I依賴類B,類C通過介面I依賴類D,如果介面I對於類B和類D來說不是最小介面,則類B和類D必須去實現他們不需要的方法。什麼是介面隔離原則 介面隔離原則比較簡單,有兩種定義:Clients should not
1、Switch中可以使用String了在之前的版本中是不支援在Switch語句塊中用String類型的資料的,這個功能在C#語言中早已被支援,好在JDK1.7中加入了。String s = "test"; switch (s) { case "test" : System.out.println("test"); case "test1" : System.out.println("test1"); break ; default :
1)現在的情況是這樣的:有一個表 testtbl( id int, name varchar, level int, age int) ; 根據level的取值分為三個層級:高,中,低。 現在要統計每個age中,高、中、和低層級的數目。即通過age作group by,但在每個age值內,還要按level取值統計各層級的記錄數。解決方案:select age, (select count(*) from testtbl t2 where t2.age=t1.age and level <?)
blend為我們提供方便的behavior來擴充我們的控制項,寫好之後就可以在blend中方便的使用了。下面是自訂的behavior來實現Listbox自動滾動到選中項其中this.AssociatedObject為使用該行為的控制項。其中OnAttached()和OnDetaching()為必須重寫的內容,通常可以在OnAttched()裡面添加事件處理常式,來達到拓展的目的。public class AutoScrollBehavior : Behavior<ListBox>
文章目錄 WPF Performance Tips 轉自WPFtutorial,很好的WPF專題網站WPF Performance TipsWindows Presentation Foundation provides a very confortable way to develop rich user experiences. A drop shadow for example can added by inserting two
摘自MSDN官方文檔MSDN ListBoxUsage of the ItemsControl and ListBox are perhaps the most common places applications can experience performance problems. To use these controls correctly, you need to consider how many items you are going to display in your