Dreamine.MVVM.Locators.Wpf 1.0.7
Dreamine.MVVM.Locators.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.MVVM.Locators.Wpf.ViewModelBinder 클래스 참조

더 자세히 ...

정적 Public 멤버 함수

static bool GetAutoWireViewModel (DependencyObject obj)
static void SetAutoWireViewModel (DependencyObject obj, bool value)
static FrameworkElement ResolveView (object viewModel)

정적 Public 속성

static readonly DependencyProperty AutoWireViewModelProperty

정적 Private 멤버 함수

static void OnAutoWireViewModelChanged (DependencyObject d, DependencyPropertyChangedEventArgs e)
static ? Type FindViewType (string[] candidateTypeNames)

상세한 설명

ViewModel 자동 바인딩과 View 확인을 위한 WPF 도우미를 제공합니다.

ViewModelBinder.cs 파일의 15 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ FindViewType()

? Type Dreamine.MVVM.Locators.Wpf.ViewModelBinder.FindViewType ( string[] candidateTypeNames)
inlinestaticprivate

로드된 어셈블리에서 생성 가능한 WPF View 후보 타입을 찾습니다.

매개변수
candidateTypeNames검색할 전체 타입 이름 후보입니다.
반환값
찾은 View 타입이며, 없으면 null입니다.

ViewModelBinder.cs 파일의 215 번째 라인에서 정의되었습니다.

216 {
217 foreach (string candidateTypeName in candidateTypeNames)
218 {
219 foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
220 {
221 Type? viewType = assembly.GetType(candidateTypeName);
222 if (viewType is null)
223 {
224 continue;
225 }
226
227 if (!typeof(FrameworkElement).IsAssignableFrom(viewType))
228 {
229 continue;
230 }
231
232 if (viewType.IsAbstract)
233 {
234 continue;
235 }
236
237 return viewType;
238 }
239 }
240
241 return null;
242 }

다음에 의해서 참조됨 : ResolveView().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ GetAutoWireViewModel()

bool Dreamine.MVVM.Locators.Wpf.ViewModelBinder.GetAutoWireViewModel ( DependencyObject obj)
inlinestatic

ViewModel 자동 바인딩 활성화 여부를 가져옵니다.

매개변수
obj대상 종속성 객체입니다.
반환값
자동 바인딩이 활성화되었으면 true입니다.

ViewModelBinder.cs 파일의 56 번째 라인에서 정의되었습니다.

57 {
58 return (bool)obj.GetValue(AutoWireViewModelProperty);
59 }

다음을 참조함 : AutoWireViewModelProperty.

◆ OnAutoWireViewModelChanged()

void Dreamine.MVVM.Locators.Wpf.ViewModelBinder.OnAutoWireViewModelChanged ( DependencyObject d,
DependencyPropertyChangedEventArgs e )
inlinestaticprivate

자동 연결 속성이 활성화되면 ViewModel을 확인해 DataContext에 할당합니다.

매개변수
d변경된 종속성 객체입니다.
e속성 변경 정보입니다.

ViewModelBinder.cs 파일의 179 번째 라인에서 정의되었습니다.

180 {
181 if (d is FrameworkElement view && e.NewValue is true)
182 {
183 object? viewModel = ViewModelLocator.Resolve(view.GetType());
184 if (viewModel is not null)
185 {
186 view.DataContext = viewModel;
187 }
188 }
189 }

◆ ResolveView()

FrameworkElement Dreamine.MVVM.Locators.Wpf.ViewModelBinder.ResolveView ( object viewModel)
inlinestatic

지정한 ViewModel에 대응하는 View를 확인하고 DataContext에 ViewModel을 할당합니다.

매개변수
viewModelViewModel 인스턴스입니다.
반환값
확인 및 생성된 View 인스턴스입니다.
예외
ArgumentNullExceptionviewModelnull인 경우 발생합니다.
InvalidOperationException전체 타입 이름이나 대응 View 타입을 확인하지 못한 경우 발생합니다.

ViewModelBinder.cs 파일의 130 번째 라인에서 정의되었습니다.

131 {
132 if (viewModel is null)
133 {
134 throw new ArgumentNullException(nameof(viewModel));
135 }
136
137 Type viewModelType = viewModel.GetType();
138 string fullName = viewModelType.FullName
139 ?? throw new InvalidOperationException($"Cannot determine the full type name for {viewModelType.Name}.");
140
141 string[] candidates = ViewNamingConvention.GetViewTypeNameCandidates(fullName);
142 Type? viewType = FindViewType(candidates);
143
144 if (viewType is null)
145 {
146 throw new InvalidOperationException($"Cannot find a View for candidates: {string.Join(" or ", candidates)}.");
147 }
148
149 FrameworkElement view = (FrameworkElement)Activator.CreateInstance(viewType)!;
150 view.DataContext = viewModel;
151
152 return view;
153 }

다음을 참조함 : FindViewType().

다음에 의해서 참조됨 : Dreamine.MVVM.Locators.Wpf.ContentControlNavigator.Navigate(), Dreamine.MVVM.Locators.Wpf.RegionBinder.Navigate().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SetAutoWireViewModel()

void Dreamine.MVVM.Locators.Wpf.ViewModelBinder.SetAutoWireViewModel ( DependencyObject obj,
bool value )
inlinestatic

ViewModel 자동 바인딩 활성화 여부를 설정합니다.

매개변수
obj대상 종속성 객체입니다.
value자동 확인 및 할당을 활성화하려면 true입니다.

ViewModelBinder.cs 파일의 85 번째 라인에서 정의되었습니다.

86 {
87 obj.SetValue(AutoWireViewModelProperty, value);
88 }

다음을 참조함 : AutoWireViewModelProperty.

멤버 데이터 문서화

◆ AutoWireViewModelProperty

readonly DependencyProperty Dreamine.MVVM.Locators.Wpf.ViewModelBinder.AutoWireViewModelProperty
static
초기값:
=
DependencyProperty.RegisterAttached(
"AutoWireViewModel",
typeof(bool),
typeof(ViewModelBinder),
new PropertyMetadata(false, OnAutoWireViewModelChanged))
static void OnAutoWireViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

View의 DataContext에 ViewModel을 자동 할당하는 연결 속성입니다.

ViewModelBinder.cs 파일의 25 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : GetAutoWireViewModel(), SetAutoWireViewModel().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: