반응형

WPF 47

[WPF] UserControl DependencyProperty 설정과 Binding 방법

자주 쓰이는 UserControl을 만들 때, 해당 컨트롤을 바딩인 속성 설정과 실제 바인딩 방법에 대해 알아본다. Usercontrol xaml cs namespace WintexMonitoring.View { /// /// MaterialCard.xaml에 대한 상호 작용 논리 /// public partial class MaterialCard : UserControl { public string Title { get { return (string)GetValue(TitleValueProperty); } set { SetValue(TitleValueProperty, value); } } public static readonly DependencyProperty TitleValueProperty = D..

프로그래밍/WPF 2021.07.21

[WPF] ItemControl에서 Item Index binding

ItemControl 등에서 각 itemsSource에 있는 파일을 삭제 처리나 수정 처리 할 때, 방법에 따라 다양하지만 해당 ItemTemplate에 추가나 삭제 버튼을 만들어 처리하는게 일반적이다. 이때 해당 ItemsSource의 Index값을 가져와서 처리하는 방법을 알아보자. ViewModel class ConfigViewModel : DialogViewModelBase { private string _address; public string Address { get { return _address; } set { SetProperty(ref _address, value); } } public ObservableCollection IP { get; set; } public DelegateCom..

프로그래밍/WPF 2021.05.11

[WPF] Value Converter

바인딩 처리를 하다보면 값에 따라 화면에 바인딩 되어야하는 값이 달라야 할때가 있다. 예를들어 bool 값을 이용하여 visible처리 할 때나, 퍼센트 값에 따라 폰트 컬러가 달라진다거나 하는 기타 등등의 요소가 존재한다. 이를 위한 Value Converter 사용법은 아래와 같다. ViewModel에 컨버터 클래스를 선언한다. public abstract class BaseOnewayConverter : MarkupExtension, IValueConverter { public BaseOnewayConverter() { } // source to binding target public abstract object Convert(object value, Type targetType, object pa..

프로그래밍/WPF 2021.05.10

[WPF] MVVM에서 IDialogService 사용

mvvm을 사용할 때, Dialog용 Service를 만들어서 사용하는 방법을 기술하겠다. 위의 구조대로 만들 예정이다. 만약 새로운 화면이 필요하다면 커스텀 DialogView를 이용하여 처리하면 된다. IDialogWindow.cs namespace CounterMonitor.Dialogs.Service { public interface IDialogWindow { bool? DialogResult { get; set; } object DataContext { get; set; } bool? ShowDialog(); } } 창을 띄울 화면 생성 DialogWindow.xaml 해당 위의 인터페이스를 상속하자 DialogWindow.xaml.cs using System.Windows; namespace..

프로그래밍/WPF 2021.05.10

[WPF] IGrouping 데이터 바인딩 하기

LINQ를 사용하다보면 group를 사용하여 그룹화를 시켜줄 때가 많다. 이때, group 사용 시에 IGrouping Interface를 반환받게 되는데 이것을 데이터 바인딩 하는 방법을 알아본다. Model DTO public class IoTStatus : BindableBase { private int _line; public int Line { get { return _line; } set { SetProperty(ref _line, value); } } private int _table; public int Table { get { return _table; } set { SetProperty(ref _table, value); } } } Service public async Task GetI..

프로그래밍/WPF 2021.05.06
반응형