特定のWPFコントロールを[VS 2017]デザイナーにのみ表示する必要がありますが、実行時には表示する必要はありません。 (具体的には、コンポーネントをレイアウトするための背景画像)。
As I learned, the opposite effect (hiding a control at design time) can be achieved using the undocumented d:IsHidden="true"
attribute, from the namespaces that are typically included even by default:
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
他の機能があります。 > d:DesignStyle
しかし、 d:Visible
のようなもの、あるいはそれに効果のあるものが見つかりませんでした。
それで、特別な 'd'属性を持つのと同じように、デザイン時のみのコンポーネントを持つための単純なメソッドはありますか?私はカスタムのビハインドビハインドを使わないことを望みます。それは少なくとも些細な(しかし厄介な)解決策があるからです:ただコンパイルの前にコンポーネントをコメントアウトするだけです!
理想的には、コンポーネント全体を実行時に無効化または削除して、リソースが消費されないようにする必要があります。
もっと一般的に言えば、 d
名前空間のこれらの「文書化されていない」機能をすべて見つける方法はありますか?
'd'は魔法でも公式でもありません。これは、それが定義されているxaml/XMLファイルに対してローカルなxml名前空間の別名です。
この行は、問題のコードでdを定義しています。
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
So to find information about 'features' of this namespace there should be a list of all classes that are in this namespace. Most of them are in the Microsoft Expression Blend SDK: https://www.microsoft.com/en-us/download/details.aspx?id=22829
'd'は魔法でも公式でもありません。これは、それが定義されているxaml/XMLファイルに対してローカルなxml名前空間の別名です。
この行は、問題のコードでdを定義しています。
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
So to find information about 'features' of this namespace there should be a list of all classes that are in this namespace. Most of them are in the Microsoft Expression Blend SDK: https://www.microsoft.com/en-us/download/details.aspx?id=22829
InitializeComponent()呼び出しの後に、これをWindowまたはUserControlコンストラクターに入れることができます。
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
{
myDesignControl.Visibility = Visibility.Collapsed;
}
これを実行すると、実行時にコントロールを再びオンにすることもできます。これは、ツールのデバッグや診断に役立つことがよくあります。
InitializeComponent()呼び出しの後に、これをWindowまたはUserControlコンストラクターに入れることができます。
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
{
myDesignControl.Visibility = Visibility.Collapsed;
}
これを実行すると、実行時にコントロールを再びオンにすることもできます。これは、ツールのデバッグや診断に役立つことがよくあります。