:DependencyProperty에 실버 라이트 UserControl을
나는 CreateRuleItemView라는 UserControl을 내가 여기에 종속성 속성을 추가 할 수 있습니다 내 ViewModel도 바인딩 할 수 있습니다. 지금까지 나는 가지고있다. 내가 다음 사용자의 컨트롤 XAML을 속성에 액세스하려고하면
public partial class CreateRuleItemView : UserControl
{
public CreateRuleItemView()
{
InitializeComponent();
}
public Boolean ShowEditTablePopup
{
get
{
return (Boolean)this.GetValue(ShowEditTablePopupProperty);
}
set
{
this.SetValue(ShowEditTablePopupProperty, value);
}
}
public static readonly DependencyProperty ShowEditTablePopupProperty = DependencyProperty.Register("ShowEditTablePopup", typeof(Boolean), typeof(CreateRuleItemView), new PropertyMetadata(null, OnShowEditTablePopupChanged));
private static void OnShowEditTablePopupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}
}
}
내가 얻을 : 멤버 "ShowEditTablePopup"
<UserControl x:Class="Views.Setup.CreateRuleItemView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance Type=vm:CreateRuleItemViewModel, IsDesignTimeCreatable=False}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400" ShowEditTablePopup="{Binding DataContext.ShowEditTablePopup}" >
오류 1가 인식되지 않거나 액세스 할 수 없습니다입니다.
오류 3 속성 'ShowEditTablePopup은'유형 'UserControl을'
오류 2 속성 'ShowEditTablePopup'유형에서 찾을 수 없습니다에 존재하지 않는 'UserControl을'.
편집 1 : Ok 내 기본 설정 창에서 코드를 바인딩하여이 문제를 해결할 수 있습니다.
Setup.CreateRuleItemView v = new Setup.CreateRuleItemView();
BindingOperations.SetBinding(v, CreateRuleItemView.EditTablePopupProperty, new Binding("EditTablePopup"));
안녕하세요. 나는 내 View를 할당 할 때 Code 내 Binding을 추가하기 위해이 문제를 해결할 수 있었다. –
차가워지면 어떻게되는지 알려주세요. –