2
一直在尋找並試圖讓我的按鈕有不同的選擇區域(比方形)。製作圓形選區並不難,但是這種弧形,我找不到一個好的答案。 我想爲Visual Studio這樣做在Blend 2013年在wpf和C中製作自定義形狀的按鈕#
我當前的代碼是:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="RoundUI.MainWindow"
Title="MainWindow" Height="350" Width="525"
AllowsTransparency="True"
OpacityMask="White"
WindowStyle="None"
Background="Transparent">
<Grid MouseLeftButtonDown="Window_MouseLeftButtonDown" MouseMove="Grid_MouseMove">
<Grid.Background>
<ImageBrush ImageSource="smileface.png" />
</Grid.Background>
<Image x:Name="image" HorizontalAlignment="Left" Height="100" Margin="212,29,0,0" VerticalAlignment="Top" Width="100" Source="nool.png" RenderTransformOrigin="0.5,0.5" MouseDown="Image_MouseDown_1" MouseEnter="Image_MouseEnter_1" MouseLeave="Image_MouseLeave" Stretch="Fill" >
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
<Image.Clip>
<EllipseGeometry Center="50,50" RadiusX="45" RadiusY="45" />
</Image.Clip>
</Image>
<Image HorizontalAlignment="Left" Height="100" Margin="212,214,0,0" VerticalAlignment="Top" Width="100" MouseDown="Image_MouseDown" Source="nool.png" MouseEnter="Image_MouseEnter_2" MouseLeave="Image_MouseLeave_1" Stretch="Fill" Cursor="IBeam" ToolTip="Hello" />
<Ellipse Height="100" Width="100" Margin="317,156,108,94" MouseEnter="Ellipse_MouseEnter" MouseLeave="Ellipse_MouseLeave" MouseDown="Ellipse_MouseDown">
<Ellipse.Fill>
<ImageBrush ImageSource="Arc.png"/>
</Ellipse.Fill>
</Ellipse>
<TextBlock x:Name="infoBlock" HorizontalAlignment="Left" Margin="229,172,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" FontSize="16"/>
<TextBlock x:Name="clickBlock" HorizontalAlignment="Left" Margin="354,135,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>
<Image x:Name="close" HorizontalAlignment="Left" Visibility="Hidden" Source="nool.png" Height="52" Margin="376,10,0,0" VerticalAlignment="Top" Width="69" MouseDown="close_MouseDown"/>
</Grid>
</Window>
我的問題是,我怎樣才能使這個綠地面積只有點擊。這將是很好的,如果它可以是所有形狀的通用代碼。
http://stackoverflow.com/questions/6101823/filled-arcs-in-wpf – Sajeetharan