본문 바로가기

WPF

WPF에서 Window Message 다루기 You can do this via the System.Windows.Interop namespace which contains a class named HwndSource. using System; using System.Windows; using System.Windows.Interop; namespace WpfApplication1 { public partial class Window1 : Window { public Window1() { InitializeComponent(); } protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource source = PresentationSo.. 더보기
[MVVM-Light]Implementing Progress bar using WPF with MVVM pattern(using BackgroundWorker) ProgressbarSampleView.xaml ProgressarSampleViewModel.cs namespace MyProject { public class ProggressbarSampleViewModel: ViewModelBase { private readonly BackgroundWorker worker; private readonly ICommand instigateWorkCommand; public ProggressbarSampleViewModel() { this.instigateWorkCommand = new RelayCommand(o => this.worker.RunWorkerAsync(), o => !this.worker.IsBusy); this.worker = new Backgrou.. 더보기
[MVVM-Light] View와 View 사이 통신 In the constructor of your MainPage (or whatever): Messenger.Default.Register(this, MessageReceived); The MessageReceived method (also in MainPage): private void MessageReceived(string message) { if (message == "SomeTabWasClosed") { //Do the necessary clean-up } } Then when you need to send the message (maybe in your tab Views or their ViewModels): Messenger.Default.Send("SomeTabWasClosed"); 더보기
[MVVM-Light]ViewModel 간 values 전달 The easiest way is to pass MainWindowViewModel's instance to OpenFileViewModel: public class OpenFileViewModel { private MainWindowViewModel _parent; public OpenFileViewModel(MainWindowViewModel parent) { _parent = parent; } After that you can call/access any public method/property in MainWindowViewModel: foreach (var item in _parent.myList) { ... } After a bit research I got the Current instanc.. 더보기
[WPF]데이터를 정렬하는 ListView 샘플 MSDN - http://msdn.microsoft.com/ko-kr/library/ms771680(v=vs.90).aspx 더보기
[WPF]ListView의 Scrollbar가 자동으로 현재 진행 중인 row에 맞게 아래로 동작 You have to add a reference to System.Windows.Interactivity to use Behavior class Behavior public class ScrollIntoViewForListView : Behavior { /// /// When Beahvior is attached /// protected override void OnAttached() { base.OnAttached(); this.AssociatedObject.SelectionChanged += AssociatedObject_SelectionChanged; } /// /// On Selection Changed /// /// /// void AssociatedObject_SelectionChanged(.. 더보기