【发布时间】:2014-08-17 21:03:31
【问题描述】:
我有一个带有按钮的窗口,我需要删除它或者不取决于传递给窗口的参数:
public MainWindow(bool removeControl)
{
InitializeComponent();
if (removeControl)
{
//code to remove the button
}
}
在 XAML 文件中,我声明了一个普通按钮:
<Button Width="120" Height="25" Content="Click" Name="ClickButton"></Button>
我知道这可以通过做相反的事情来完成,这意味着根据布尔参数添加按钮,但我需要这样做。
【问题讨论】: