VisualStudio/WPF 11

[WPF] WPF와 Unity연동 방법

※Unity 빌드 파일을 Wpf 빌드파일에 넣어야 실행된다. MainWindow.cs에 _process.StartInfo.FileName = ""; 안에 Wpf 빌드파일에 들어있는 Unity 빌드파일 명을 기입하면된다. MainWindow.xaml MainWindow public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += attemptInit; dispatcherTimer...

VisualStudio/WPF 2023.01.20

[WPF] Win32 api 사용하여 윈도우 창 제어하기 max창 드레그 및 축소화

public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); private void pnlControlBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { WindowInteropHelper helper = new WindowInteropHelper(this); SendMessage(helper.Handle, 161, 2, 0); //DragM..

VisualStudio/WPF 2023.01.09

[WPF] 바인딩(onetime, oneway, twoway, onewaytosource)

C#에서 인터페이스에 나타나는 값을 동적으로 표현할때 데이터바인딩을 사용한다. XAML의 내용이 이렇게 선언하면 TEXTBOX안에 표시되는 내용이 ViewModel이라는 뷰모델 클래스의 name이라는 요소와 연결되게 된다. 여기서 설정하는 MODE는 onetime, oneway, twoway, onewaytosource 중에 하나로 설정하는데, -onetime 만약에 현재 뷰모델의 name이라는 요소가 string타입의 "사과"라고 저장되어 있다고 하자. 만약 MODE를 onetime으로 연결 한다면, 인터페이스의 텍스트블록 안에 "사과"라는 글자가 뜨게 된다. 하지만, 이때 단 한번만 바인딩이 되고 이후로는 연결이 끊어지게 되서 뷰모델 안의 string name을 바꿔도 텍스트 박스의 값이 영향을 받지..

VisualStudio/WPF 2023.01.09

[WPF] 사용자 정의컨트롤 디펜던시프로퍼티(DependencyProperty)

디펜던시프로퍼티 사용자 정의컨트롤을 만들어 사용 할 때 사용자 정의 컨트롤의 속성을 접근하여 get set을 하기 위한 프로퍼티 이다. 사용방법 정의컨트롤 생성 디펜던시 프로퍼티 생성 방법 PROPDP + Tab + Tab 하면 나오는 초기 디펜던시 프로퍼티 public int MyProperty { get { return (int)GetValue(MyPropertyProperty); } set { SetValue(MyPropertyProperty, value); } } // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... public static re..

VisualStudio/WPF 2023.01.05