ExpanderにDockPanel.Dockをアタッチできますが、ToggleButton.IsCheckedをアタッチできません。どうして?ToggleButton.IsCheckedプロパティをエキスパンダーにアタッチできない
<Expander DockPanel.Dock='Bottom'> <!--Compile-->
<Expander ToggleButton.IsChecked='True'> <!--Doesn't compile-->
私はソースで答えを見つけました:ToggleButtonから
:
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register(
"IsChecked",
typeof(bool?),
typeof(ToggleButton),
new FrameworkPropertyMetadata(
BooleanBoxes.FalseBox,
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal,
new PropertyChangedCallback(OnIsCheckedChanged)));
フォームDockPanel:
public static readonly DependencyProperty DockProperty =
DependencyProperty.RegisterAttached(
"Dock",
typeof(Dock),
typeof(DockPanel),
new FrameworkPropertyMetadata(
Dock.Left,
new PropertyChangedCallback(OnDockChanged)),
new ValidateValueCallback(IsValidDock));
Dock
はRegisterAttached
方法の代わりに、Register
に登録されています。
外部トグルボタンを使用してエクスパンダを拡張しようとしているのですか、単にエクスパンダをデフォルトで拡張しようとしていますか? –
私は単にこのエキスパンダーに "IsChecked"プロパティを追加しようとしています。これは、 "IsExpanded"プロパティにバインドされることを意図しない。 –
Expanderが 'ToggleButton'を持っていて、' ToggleButton'の 'ControlTemplate'の一部として独自の' IsChecked'プロパティで独自の状態を設定している理由は分かりません。認知症の答えはあなたの質問に答えます。 –