2021/052 WPF Control 이미지 저장하기 WPF의 Control을 이미지를 저장하는 방법입니다. 1. 아래와 같이 Grid에 Image, TextBox로 구성했습니다. Grid내의 Control을 이미지로 저장 할 겁니다. XAML 2. Grid Control인 grStamp를 이미지로 저장하는 소스입니다. RenderTargetBitmap rtb = new RenderTargetBitmap((int)grStamp.ActualWidth, (int)grStamp.ActualHeight, 96, 96, PixelFormats.Pbgra32); rtb.Render(grStamp); PngBitmapEncoder png = new PngBitmapEncoder(); png.Frames.Add(BitmapFrame.Create(rtb)); MemoryS.. 2021. 5. 20. WPF - WebBrowser에 사이트 연결 오류 시 처리하기. 웹브라우저에 네트워크가 문제로 연결 안될 경우 처리 방법입니다. 메세지를 표시하던가 아니면 로컬의 HTML 페이지를 표시하기 위한 방법입니다. 1. XAML에 WebBrowser를 추가합니다. 2. Window Loaded 이벤트나 생성자에 아래의 코드로 처리하면 됩니다. try { WebRequest request = WebRequest.Create(url); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { webBrowser.Source = new Uri(url); } else { throw new Exception(); } } catch { M.. 2021. 5. 7. 이전 1 다음