4월, 2014의 게시물 표시

System.Windows.Input.ICommand 구현

         public   bool   CanExecute ( object   parameter )         {              return   _imageData . ImagePath   !=   null ;         }          public   event   EventHandler   CanExecuteChanged         {              add  {  CommandManager . RequerySuggested   +=   value ; }              remove  {  CommandManager . RequerySuggested   -=   value ; }         } 잘 이해는 안 된다... ㅠㅠ. WPF가 바인딩된 모든 Command들의 실행 가능 상태가 바뀔 때로 예상되면, 실행하는 CommandManager.RequerySuggestedstatic event 에등록....

Blendability : Degign 모드에 DataContext 설정

뷰의 xaml 코드에 다음을 추가. < Window  x : Class = "WpfApplication1.Window1"          xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"          xmlns : x = "http://schemas.microsoft.com/winfx/2006/xaml"           xmlns : d = "http://schemas.microsoft.com/expression/blend/2008"          xmlns : mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"          mc : Ignorable = "d"          d : DataContext ="{ d : DesignInstance  Type = local : ImageData ,  IsDesignTimeCreatable = True } "          xmlns : local = "clr-namespace:WpfApplication1"          Title = "Window1"  Height = "452"  Width = "624.972" > 그리...

Why MVVM?

The event handler is part of the "code behind" where the UI is declared, typically a window or a user control. This makes it difficult to call from other objects that may want to invoke the same logic. The aforementioned button may disappear and be replaced by (say) a menu item. This would require the event hooking code to potentially change. What if we wanted both a button and a menu item? An action may not be allowed at a certain state – the button (or whatever) needs to be disabled or enabled at the right time. This adds management overhead to the developer – the need to track state and change it for all UI elements that invoke the same functionality. An event handler is just a method – there's no easy way to pick it up and save it somewhere, such as for undo/redo purposes. It's difficult to test application logic without using actual user interface. These, and other, more subtle issues, make working with event handlers less than ideal, especially when app...