ControlTemplate 触发器在设计器中不起作用(运行时正常)

ControlTemplate Trigger don't work in designer (runtime ok)

我有一个自定义控件派生自 Window:

class LVSDialog : Window

具有依赖性属性 ShowCloseButton

以及带有 ControlTemplate 和触发器的样式:

<Style TargetType="{x:Type loc:LVSDialog}" x:Key="LVSDialogStyle">
    ...
    <Setter Property="Template">
        ...
        <Button x:Name="closeButton" />
        ...
        <ControlTemplate.Triggers>
            <Trigger Property="loc:LVSDialog.ShowCloseButton" Value="False">
                <Setter TargetName="closeButton" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>            
    </Setter>

运行时一切正常,但在 Designer 中,如果我更改此设置则没有意义 属性 - 按钮始终可见:

<loc:LVSDialog ...
    ShowCloseButton="False" Style="{StaticResource LVSDialogStyle}">

我在 google 和此处搜索了解决方案 - 所有问题都与运行时功能有关,设计人员的问题要么没有答案,要么没有工作建议。

是否有可能在设计时使用全部功能?

P.S。我的 VisualStudio 是 2012.Framework 4.0

如果将基数 class 改为 Control 而不是 Window 它将起作用:

  public class LVSDialog : Control
  {


    public bool ShowCloseButton
    {
      get { return (bool)GetValue(ShowCloseButtonProperty); }
      set { SetValue(ShowCloseButtonProperty, value); }
    }

    // Using a DependencyProperty as the backing store for ShowCloseButton.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty ShowCloseButtonProperty =
        DependencyProperty.Register("ShowCloseButton", typeof(bool), typeof(LVSDialog), new PropertyMetadata(true));


  }

From Topicstarter:

我已更改为控件,添加了内部 window,将其内容设置为我的控件并添加了 Show() 和 ShowDialog() 方法:

private Window parentWindow;
...
public void Show()
{
    if (parentWindow == null)
    {
        parentWindow = new Window {Content = this, WindowStyle = ...};
    }
    parentWindow.Show();
}

一切正常,设计器显示所有属性 "live"。