C# WPF画布中的形状不显示
我遇到了一个非常奇怪的问题,在WPF中在画布上绘制形状C# WPF画布中的形状不显示,c#,wpf,canvas,drawing,C#,Wpf,Canvas,Drawing,我遇到了一个非常奇怪的问题,在WPF中在画布上绘制形状 <DockPanel Grid.Row="3"> <Canvas Name="BottomCanvas" Margin="15" Background="Yellow"> <Canvas Name="TransparentCanvas" Background="Transparent" MouseDown="
<DockPanel Grid.Row="3">
<Canvas Name="BottomCanvas" Margin="15" Background="Yellow">
<Canvas Name="TransparentCanvas" Background="Transparent"
MouseDown="TransparentCanvas_MouseDown"
MouseUp="TransparentCanvas_MouseUp"
MouseMove="TransparentCanvas_MouseMove"
Width="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Canvas}},Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Canvas}},Path=ActualHeight}">
</Canvas>
</Canvas>
</DockPanel>
有人能看出哪里出了问题吗
编辑:
我很抱歉。正如您在XAML画布中看到的,它被命名为“BottomCanvas”,在代码中我使用了
BottomCanvas
,这是一个添加到MainWindow
的属性,我不知道它的用途。那就是交易。你的意思是椭圆不可见?这只是因为SolidColorBrush
的透明填充。Color
的Alpha
值不应为零,这意味着不可见。如果是这样,只需更改颜色的Alpha
值即可:
mySolidColorBrush.Color = Color.FromArgb(255, 0, 255, 0);
这是一个很有观察力的通知。谢谢@你能接受这个答案吗?这样其他人就可以很快解决这个问题了?
mySolidColorBrush.Color = Color.FromArgb(255, 0, 255, 0);