내 응용 프로그램에서 주 모듈 트로프 코드를로드하려고합니다. 모든 것은 렌더링 시점까지 작동하며 왜 렌더링하지 않는지 전혀 모른다. 내용은 올바른 가치와 모든 것을 가지고 있습니다. 내 추측은 무언가 wobbly wobbly로 갔고 나는 그것을 놓치고있는 것 같습니다. 쉘 뷰를모듈 렌더링 안 함
[ContentPropertyAttribute("ContentView")]
public class ContentControlExtened : ContentControl
{
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register(
"Type",
typeof(Type),
typeof(ContentControl),
new FrameworkPropertyMetadata(null, ContentTypeChanged));
public static readonly DependencyProperty ContentViewProperty =
DependencyProperty.Register(
"View",
typeof(FrameworkElement),
typeof(ContentControl),
new FrameworkPropertyMetadata(null, ContentViewChanged));
private static void ContentViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//throw new NotImplementedException();
}
public ContentControlExtened()
{
this.Loaded += ContentControlLoaded;
}
private void ContentControlLoaded(object sender, RoutedEventArgs e)
{
this.LoadContent();
}
private void LoadContent()
{
UserControl u = null;
if (Type != null)
{
u = (UserControl)ServiceLocator.Current.GetInstance(this.Type);
}
u.Background = new SolidColorBrush(Color.FromRgb(0, 0, 255));
this.View = u;
}
public Type Type
{
get { return (Type)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
public FrameworkElement View
{
get { return (FrameworkElement)GetValue(ContentProperty); }
set
{
SetValue(ContentProperty, value);
}
}
}
방법을 보유하고있다
Control은 MAINVIEW의 생성자가 정직 주어진 moduleInfo
private void OpenMainView(ModuleInfo module)
{
Type moduleType = Type.GetType(module.ModuleType);
var moduleMainViewType = moduleType.Assembly.GetType(moduleType.Namespace + ".Views.MainView");
this.ContentHolder.MainContent.Type = moduleMainViewType;
}
의 메인 뷰를로드한다. 표준 컨트롤 인 InitializeComponent()와 Datacontext가 servicelocator를 통해 설정됩니다.
DP의 Getter 및 Setter가 누락되었습니다. –
그들은 문제가 아니기 때문에 그냥 게시하는 것을 신경 쓰지 않았습니다 :) –
'ContentType'은 무엇입니까? 네 DP가 뭔가 잘못 됐나 봐. –