-1
我正在WPF C#項目上工作,並試圖通過CheckBox
(如果它是Checked
,將顯示形狀)顯示我的形狀。 我做當CheckBox被選中時隱藏和顯示形狀
Visibility triangle = Visibility.Hidden;
public MainWindow()
{
InitializeComponent();
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
Visibility triangle = Visibility.Visible;
}
和XAML:
<Polygon MouseDown="Window_MouseDown" MouseLeftButtonDown="shape_MouseLeftButtonDown"
MouseLeftButtonUp="shape_MouseLeftButtonUp" MouseMove="shape_MouseMove"
AllowDrop="True" x:Name="triangle" Stroke="Purple" StrokeThickness="2" Canvas.Left="482"
Canvas.Top="176" Height="30" Width="41">
<Polygon.Fill>
<SolidColorBrush Color="Blue" Opacity="0.4"/>
</Polygon.Fill>
</Polygon>
它仍然沒有工作。是否有另一種方式來顯示或隱藏WPF中的形狀?或者你能幫我找到我的代碼問題嗎?
你的形狀是什麼名字? –
名稱是三角形 – chris
'triangle.Visibility = Visibility.Visible;' –