ツールチップの可視性ステータスを含む静的変数を保持するクラスがある場合、可視性変数が変更されたときにツールチップの可視性を動的に変更するためのコードビハインドをどのように記述しますか?
つまり、ツールチップオプションが無効になっている場合、ツールチップは表示されませんが、ツールチップオプションが有効になっている場合、ツールチップは表示されます。(ツールチップオプションは別のクラスの静的変数に保持されます)ツールチップとそれが接続しているコントロールは動的に作成されます。
擬似コード:
ToolTip myToolTip = new ToolTip();
Visiblity tooltipVis = Visibility.Visible;
Bind myToolTip.Visiblity to toolTipVis
//Any control with ToolTip should now show their respective ToolTip messages.
...
tooltipVis = Visibility.Hidden;
//Any control with ToolTip should now have ToolTip messages disabled
TreeViewItemへのバインドを試みます:
TreeViewItem tvi = new TreeViewItem() { Header = tviHeader };
ToolTip x = new System.Windows.Controls.ToolTip();
x.Content = "This is text.";
Binding binder = new Binding {
Source = EnvironmentalVariables.ToolTipVisibility,
Path = new PropertyPath("Visibility")
};
x.SetBinding(VisibilityProperty, binder);
user.ToolTip = x;
public class EnvironmentalVariables {
public static Visibility ToolTipVisibility { get; set; }
}
これは、VisiblityをEnvironmentalVariables.ToolTipVisibility変数にバインドしていないようです。