본문 바로가기

WPF13

WPF MVVM TextBlock Foreground Binding WPF MVVM으로 View에 TextBlock을 Model에서 글자 색을 변경하기 위해서 Binding을 해서 사용할 수 있다. TextBlock의 Foreground는 Color가 아니라 Brush를 사용한다. 아래 예제는 CheckBox를 값이 변경 될 때 TextBlock의 Text의 내용과 Color가 변경 되게 하는 예제이다. Change Text Color 위와 같이 CheckBox를 만들어 bChecked = True이면 아래 TextBox의 checkStatus의 글자와 색상을 변경하도록 하려고 한다. public string checkStatus { get; set; } = "Selected"; public System.Windows.Media.Brush checkBrush { get;.. 2023. 6. 16.
WPF MVVM Window Close Action 처리 WPF MVVM으로 Window View와 Model 분리가 되어 있을 때 OK, Cancel 버튼을 눌러 Window를 닫는 방법이다. 간단하게 Close Action을 이용해서 닫을 수도 있는데 DialogResult를 받아서 처리를 할 때는 아래와 같이 처리해서 사용을 했다. https://learn.microsoft.com/en-us/dotnet/api/system.action-1?view=net-7.0 Action Delegate (System) Encapsulates a method that has a single parameter and does not return a value. learn.microsoft.com 다른 방법도 많을 것이다. 아래 예제는 System에서 제공하는 delega.. 2023. 6. 15.
C# UI Thread 에러 발생할 경우 C#에서 UI Thread 오류가 발생할 경우 아래와 같이 하나의 UI가 끝날 때까지 DoEvents() 함수를 호출하고 일정 시간이 지난 후에 UI 변경을 하도록 처리한다. for (int i = 0; i < 10; i++) { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(1); } Tree의 Popup 메뉴로 창을 띄우는 코드를 하는데 Tree가 선택되어 Expand 되는 도중에 ShowDialog가 호출되어 UI Thread 오류가 발생했다. 그래서 Expand가 끝나는 시간까지 DoEvents 함수를 호출하게 한 후에 ShowDialog가 호출되니 오류가 발생하지 않았다. 2023. 2. 13.
WinForm안에 있는 WFP 창에서 owner를 지정하는 방법 WFP에서 Owner를 지정할 아래와 같이 사용할 수 있다. Owner = Application.Current.MainWindow; 그런데 WinForm안에 WPF를 이용할 때 WPF의 Dialog Owner를 기존과 같은 방식으로하면 Current가 null 에러가 발생한다. WinForm에서부터 Window Handle을 넘겨 받아 사용할 수도 있지만 아래와 같이 Process에서 Handle을 받아서 처리를 할 수도 있다. WPFTestView dlg = new WPFTestView(); System.IntPtr iMainHandle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; System.Windows.Interop.Win.. 2023. 2. 8.
Telerik RadRibbonView Example (리본바 메뉴 예제) Telerik을 리본바 메뉴 윈도우를 만들어 보았다. 홈페이지의 Getting Started를 보면 쉽게 만들수 있지만 나처럼 WPF, Telerik 초보자를 위해서 만드는 과정을 정리해 본다. 잊으면 나중에 다시 볼 수 있도록~ https://docs.telerik.com/devtools/wpf/controls/radribbonview/gettingstarted WPF RibbonView | Getting Started | Telerik UI for WPF This tutorial will walk you through the creation of a sample application that contains RadRibbonView. In order to use the RadRibbonView con.. 2022. 1. 19.
Telerik Menu 추가 1. Telerik Menu 추가 Document https://docs.telerik.com/devtools/wpf/controls/radmenu/getting-started#add-radmenu WPF Menu | Getting Started | Telerik UI for WPF docs.telerik.com Document를 확인해 보니 메뉴를 추가할 때 Blend를 사용한다. Blend를 사용해본 적이 없는데 관련 내용은 MSDN을 보고 참고 했다. https://docs.microsoft.com/ko-kr/visualstudio/xaml-tools/creating-a-ui-by-using-blend-for-visual-studio?view=vs-2022 Blend for Visual Studio.. 2021. 12. 21.
Hierarchical RadGridView Example https://docs.telerik.com/devtools/wpf/controls/radgridview/hierarchical-gridview/basic-hierarchies WPF DataGrid | Basic Hierarchies | Telerik UI for WPF Controls / RadGridView / Hierarchical GridView RadGridView allows you to display hierarchical data in the form of nested grid views. To do so you have to define a table definition for each subset of data you want to display. Such a definition ca.. 2021. 9. 2.
RadTreeListView Example https://docs.telerik.com/devtools/wpf/controls/radtreelistview/radtreeliestview-getting-started#radtreelistview-vs-radgridview WPF TreeListView | Getting Started | Telerik UI for WPF This article will guide you through the process of creating a sample application with RadTreeListView. You should use the RadTreeListView control to display hierarchical data in a tabular format. In order to achieve.. 2021. 9. 2.
WPF MVVM TextBox KeyDown Event WPF로 MVVM 패턴을 이용해서 TextBox의 KeyDown 이벤트를 확인해서 검색이나 다른 기능을 실행 시키기 위해서 처리하는 방법을 검색해서 만들어 보았다. 프로젝트에 Notifier.cs와 DelegateCommnad.cs를 추가한다. ViewModel.cs를 만들어 DataContext에 연결한다. MainWindow.xaml에는 TextBox 하나를 추가했다. http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc=" MainWindow.xaml.cs에서 DataContext 연결을 한다. public partial c.. 2021. 7. 20.
LIST