programing

WPF를 배울 때 가장 이해하기 어려운 점은 무엇입니까?

nasanasas 2020. 11. 27. 08:10
반응형

WPF를 배울 때 가장 이해하기 어려운 점은 무엇입니까?


어떤 WPF를 했습니까?

  • 이해하기가 가장 어렵다
  • 오랫동안 오해 받거나

그리고 결국 어떻게 이해 했습니까 (링크 등을 제공하십시오).

(WPF 학습을 안내하기 위해 이것을 요청하고 있습니다)


너무 오래 걸려서 죄송합니다 ... 도움이 되길 바랍니다! 제가 언급하고 싶은 한 가지는 이것이 저를 괴롭힌 개념 / 것이라는 것입니다. 막 시작하는 경우 공부할 항목 목록으로 사용할지 모르겠습니다. 권의 책 을 읽고 많은 블로그 ( Josh Smith , Dr. WPF )를 읽었 으며 일반적으로 작은 프로젝트에 들어가서 시도해 보았습니다 .

핵심 개념

  • 논리 및 시각적 트리 (링크 : 1 )

    WPF의 다양한 트리 이해. 특히 논리 트리와 시각적 트리를 이해하고 데이터 템플릿, 컨트롤 템플릿 등을 통해 논리 트리의 요소가 시각적 트리로 확장되는 방식을 이해합니다.

  • 종속성 속성 시스템 (링크 : 1 , 2 )

    WPF의 전체 종속성 속성 시스템을 이해하는 것은 처음 보는 것보다 훨씬 큽니다. 물론 빠른 종속성 속성을 만든 다음이를 사용하여 데이터 바인딩 및 애니메이션과 같은 다른 WPF 개념을 강화하는 것은 쉽지만 시작됩니다.

    일반적인 종속성 속성이 있고 연결된 종속성 속성이 있습니다. 그것들을 모두 등록하는 다양한 방법과 설정할 수있는 다양한 메타 데이터 옵션이 있습니다.

    이 문제를 종속성 속성이라고하는 이유를 이해하는 데 시간이 좀 걸렸습니다. 즉, 속성의 값은 여러 소스에서 제공되며 (속성은 이러한 값 공급자에 따라 다름) 주어진 시간에 최종 속성 값이 설정되는 방식에 대한 우선 순위 / 알고리즘 순서가 있음을 이해합니다.

  • 라우트 된 이벤트 (링크 : 1 , 2 )

    버블 링, 라우팅 또는 직접적 방법을 이해합니다. 라우트 된 이벤트를 연결할 수도 있음을 이해합니다 (비주얼 트리를 라우트 한 이벤트에 이벤트 처리기를 연결하는 것과 비교).

    Adam Nathan의 WPF Unleashed 의 3 장은 이러한 중요한 새로운 개념과 읽고, 프로젝트에서 작업 한 다음 다시 읽어야하는 개념을 다루는 멋진 장입니다.

    Dr. WPF의 코드 조각 은 종속성 속성, 라우트 된 이벤트 및 명령에 대해 배울 수있는 좋은 방법입니다.

그래픽 개념 (링크 : 1 )

  • 해상도 독립성 (링크 : 1 , 2 )

    WPF는 해상도 독립성의 모든 이점을 제공하지만 (모든 것을 장치 독립 픽셀로 지정) 해결해야하는 골칫거리도 있습니다. 가장 주목할만한 점은 픽셀 스냅을 활용하고 지침을 설정하는 등 원할 때 선명하게 보이도록하는 것입니다.

  • 유지 모드 대 즉시 모드

    WPF에는 유지 모드 그리기 하위 시스템이 있습니다. 즉, 그리기 지침을 추적하고 나중에 사용할 수 있도록 캐시합니다. 한 번에 모두 업데이트되는 많은 비주얼이있는 무언가를 빌드하려는 경우 성능 문제가 될 수 있습니다.

  • 컨트롤, 요소, 시각 자료 (링크 : 1 )

    WPF 계층 구조의 각 기능을 이해하고 성능에 미치는 영향을 이해합니다. 특히 템플렛, 리 스타일링 등을 할 수있는 컨트롤을 사용합니까? 아니면 강력하고 빠르게 구동 할 수 있도록 초경량 (예 : 비주얼 레이어 프로그래밍)이 필요합니까?

    Chris Sells와 Ian Griffiths는 WPF API의 다양한 유형, 계층 구조에 적합한 위치 및 가져 오는 가치에 대해 설명하는 WPF 프로그래밍 책 뒷면에 멋진 부록을 제공합니다 .

WPF 패턴

  • MVVM (Model-View-ViewModel) 패턴 (링크 : 1 )

    MVVM 패턴은 이미 WPF 방식으로 작업을 시작하는 데 도움이되는 것으로 언급되었습니다. 더 이상 동의 할 수 없습니다. 컨트롤을 데이터로 채우는 대신 데이터 템플릿을 통해 데이터를 시각적 개체로 변환하기 시작합니다.

  • 연결된 속성 동작 패턴 (링크 : 1 , 2 , 3 )

    WPF는 다른 API와 달리 확장 가능합니다. 첨부 된 속성을 사용하면 매우 우아한 방식으로 추가 동작을 구축 할 수 있으며 갇혀있을 수 있다고 생각했습니다.

WPF! = Windows Forms

누군가 이미 언급 한 것을 알고 있지만 단호하게 동의하고 싶습니다. 새롭고 다른 개념이 너무나 많기 때문에 몇 가지를 잊고 완전히 다른 각도에서 문제 해결에 접근해야합니다. 예를 들어, Windows Forms는 즉시 모드 그리기 하위 시스템이고 WPF는 유지 된 모드 (위)입니다.

WPF에서 작업을 수행하는 다양한 방법

이것은 재미있는 일이지만 WPF에서 무언가를 할 수있는 방법이 너무 많기 때문에 거의 마비되고 있습니다. 일을하는 올바른 방법은 무엇입니까? 이거예요? 그 거예요? 나는 잘못된 방식으로하는 것에 대한 두려움을 극복하고, 그냥 뛰어 들고, 내 실수로부터 배워야했습니다.


WPF는 WinForms가 아닙니다. 전부는 아니지만 WinForms에서 작업을 수행하는 데 사용하는 일반적인 전략 중 대부분은 WPF에서 잘못된 (또는 효율성이 가장 낮은) 방법입니다. 명령, 종속성 속성, 바인딩, 템플릿 등은 모두 WinForms 사고 방식을 채택하면 유용하지 않습니다.

현재 우리는 대규모 시각화 애플리케이션을 개발하고 있습니다. 노련한 WinForms 프로그래머로서 다차원 데이터 표시에서 처음으로 잘라낸 부분은 수천 개의 시각적 요소를 미리 계산했습니다. 슬라이더는 콜백을 사용하여 시각적 요소의 크기를 탐색합니다. 초기 설정 이후에는 데이터가로드되지 않습니다. 이것은 성능이 매우 나빴습니다.

수백 개의 시각적 요소에서 데이터 변환기를 사용하여 수천 개의 바인딩으로 전환하고 데이터를 즉시로드하고 다시 계산합니다. 이로 인해 성능이 대폭 향상되었습니다. 수천 개의 바인딩이 미리 계산 된 수천 개의 시각적 요소보다 빠르다는 것은 거의 상상할 수 없었지만 WPF의 경우입니다.

" WinForm에서 WPF로 : 빠른 참조 안내서 "가 유용 할 수 있습니다.


WPF를 배우기 시작했을 때 가장 어려운 점은 다음과 같습니다.

  • 스타일 및 템플릿 : 언제 어떤 것을 사용해야하며 서로 상호 작용하는지 이해하는 데 시간이 걸렸습니다.
  • RelativeSource, 변환기를 사용한 복잡한 바인딩 ...
  • 트리거 : DataTriggers, Triggers 또는 EventTriggers를 사용해야하는 위치에 대해 가끔 혼란스러워합니다 .
  • 종속성 속성 및 연결된 속성의 메커니즘
  • 라우트 된 이벤트 작동 방식

Windows Forms에 대한 경험이 있다면 처음에는 어렵게 보일 수있는 사소한 것들이 많이 있습니다. 많은 것을 잊고 UI 구조의 매우 다른 멘탈 모델로 전환해야합니다.

처음에는 많은 코드 숨김을 사용하여 Windows Forms에서 코드를 작성하기 시작했지만 확실히 올바른 방법은 아닙니다. MVVM 패턴 은 제가 WPF "철학"에 들어가는 데 정말 도움이되었습니다 ...

WPF 학습을위한 문서의 주요 소스는 물론 MSDN이었는데, 보는 방법을 안다면 대부분의 답변을 찾을 수 있습니다. 다음 블로그에서도 많은 것을 배웠습니다.


Dependency Properties took a while. Here's a nice article, and another that helped me with this new concept.

The second article contained the following paragraph that really clarified a few questions I had.

A key value of the Dependency Properties system was the ability to build properties that automatically notify any registered interested party each time the value of the property changes. This free, painless and automatic implementation of the observer pattern is tremendously powerful and greatly reduces the burden on the client programmer (in fact, the data-binding system depends on it!).

More generally, I have also found that prior experience with web development (browser UI in particular) to be very useful in "getting" WPF. It is more about the mindset it allows you to bring to WPF, compared with someone who has only ever worked with Windows Forms or other rich client applications.

Some more obvious parallels from the web world are CSS, flowing layouts, jQuery animation, event bubbling/routing and just being comfortable with the extensive browser and DHTML object models.


MMVM is a pretty tricky thing to learn. However i think its one of best things about WPF. It takes a lot of studying to get it in because they are a lot of scenarios where it is a bit difficult to implement.

As Thomas pointed out there is a lot of great material out there by the like of Josh Smith and others. Be carefull though WPF is very easy to study about but you have to use it say writing an application to see various scenarios in practice.


Data Templating (and Control Templating for that matter).

On the surface, it's reasonably straightforward, but once you start trying to setup binding between different XAML files, it can become seriously confusing.

I suppose that I finally managed to get a decent grasp through it by going through a lot of MSDN docs, but moreover, trial and error. Playing around with things is usually the best way to learn any technology.


I still cannot specify target property in animation without cheat-sheet:

<DoubleAnimation
Storyboard.TargetProperty=
"(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" 
To="1.2" Duration="0:0:.2" />

Layout is different in WPF see http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/layout-techniques-for-windows-forms-developers.aspx for how to use the layout editor


Let's take it from beginners view. I'm using simple editor like KaXML or Sharpdevelop for WPF development. and i find that i can't proceed with database development without Database grid component. So it is not like Windows forms. Start searching for commercial database grid component. and in defense people will say it is not hardest thing or limitation.

You've to work with C# files or other language files supported by .NET Framework for serious application development. If that is not makes it problematic so, why do i need to use it at first place. I'm happy with C# why do i need to use WPF ?

Hardest things so far :

  1. Data binding,
  2. Dependency on another language (C# for example),
  3. Graphics capability.

Biggest nuisance is : You can't get just another developer to work on WPF app done by a pro. This is not the case with WinForms and Asp.net where any one can work with very little problems. This is a major issue.


The differences in Binding syntax was one; i.e. when to use Binding and when to use StaticResource/DynamicResource. When I was first learning WPF, I kept getting the two mixed up.

The different forms of DP and attached properties were also hard to understand at first.


Reading through books and understanding the stuff is one thing and applying them in your project is another. I was creating a relatively simple Contact List control just like in Outlook and came across many small but noticeable learning curves.

  1. First, Templating seems simple as you are reading but it get trickier when you play with it. Just setting the background color of a user control when a text box gets focus was challenging. It turned out that I had to use DataTrigger (who would have thought).
  2. Using a wrapper as an ItemsPanel for List box all of a sudden became a challenge as it was not arranging the items (you have to play with it).
  3. Definitely RelativeSource in Binding.

Basically being able to bind controls in your template (from parent to child and vise versa) is a good learning curve.

My advice. Write a small app and you'll see thing coming together.

참고URL : https://stackoverflow.com/questions/1445114/what-did-you-find-hardest-to-understand-when-learning-wpf

반응형