我有一个控件,需要使用复选框启用禁用部分,但我需要将其绑定到一个类所以我做了以下。所以我的问题是我如何设置绑定到说例如IncidentBuilderProperty.IsEnabled我应该使用参数后面的代码。如何解决绑定问题
<DockPanel DockPanel.Dock="Top" >
<Label Content="Display" />
<CheckBox Name="chkDisplayAdvanced" IsThreeState="False" VerticalAlignment="Center"
IsChecked="{Binding isEnabled, Mode=TwoWay}" />
</DockPanel>
但在我的模型中我有属性isEnabled声明在下面的方式。
所以我的问题是我将如何访问属性IncidentBuilderProperty.isEnabled bare记住他们是每个属性与此复选框,但它引用一个自定义控件的屏幕。
public class AssignedToMeViewData : WizardData, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ManagementPack ManagmentPack { get; set; }
public List<BuilderProperties> BuilderProperty { get; set; }
public BuilderProperties GeneralPage { get; set; }
public Exception LastKnownException { get; set; }
[DefaultValue(true)]
public bool IsNew { get; set; }
public BuilderProperties IncidentBuilderProperty { get; set; }
public BuilderProperties ProblemBuilderProperty { get; set; }
public BuilderProperties ServiceRequestBuilderProperty { get; set; }
public BuilderProperties ChangeRequestBuilderProperty { get; set; }
public BuilderProperties RleaseRequestBuilderProperty { get; set; }
public BuilderProperties ReviewActivityBuilderProperty { get; set; }
public BuilderProperties ManualActivityBuilderProperty { get; set; }
public class BuilderProperties
{
private bool isEnabled = true;
public bool IsEnabled {
get {
return isEnabled;
}
set {
if (isEnabled == value)
return;
isEnabled = value;
}
}
}
}
取而代之的回报,为什么不能你写的,如果(的IsEnabled =价值!) 的IsEnabled =值; – 2014-10-02 15:45:43
@kishoreVM问题不在于我如何写入属性,而是如何在绑定中访问它,请保持主题谢谢。 – rogue39nin 2014-10-02 15:47:27
试试这个:IsChecked =“{绑定路径= IncidentBuilderProperty.IsEnabled,Mode = TwoWay} – vidriduch 2014-10-02 15:49:41