我很难搞清楚为什么这不起作用。 我把图片属性放到"内容"也一无所有。
这是我的代码:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Width="744.09448819" Height="1052.3622047">
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2" Width="744.09448819" Height="1052.3622047">
<Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="726" Height="577" Name="rect3336" Fill="#FFECECEC"/>
<Ellipse Canvas.Left="10" Width="263" Canvas.Top="10" Height="137" Name="path3340" Visibility="Visible">
<Ellipse.Fill>
<ImageBrush ImageSource="Images/1.PNG"/>
</Ellipse.Fill>
</Ellipse>
<TextBlock Name="my_TB" Width="{Binding ElementName=path3340, Path=Width}"
Height="49" TextAlignment="Center" Foreground="Black"
Text="Avatar" Canvas.Left="10" Canvas.Top="53" FontSize="36"/>
<Ellipse xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="218" Width="266" Canvas.Top="152" Height="143" Name="ellipse2" Fill="#FFFF00FF" MouseDown="ellipse2_MouseDown"/>
<Ellipse xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="404" Width="266" Canvas.Top="300" Height="143" Name="ellipse3" Fill="#FFFF00FF" MouseDown="ellipse3_MouseDown"/>
</Canvas>
</Window>
如果我将其更改为此,则可以:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Width="744.09448819" Height="1052.3622047">
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2" Width="744.09448819" Height="1052.3622047">
<Rectangle xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="726" Height="577" Name="rect3336" Fill="#FFECECEC"/>
<Ellipse Canvas.Left="10" Width="263" Canvas.Top="10" Height="137" Name="path3340" Fill="#FFFF00FF" MouseDown="ellipse_MouseDown">
</Ellipse>
<TextBlock Name="my_TB" Width="{Binding ElementName=path3340, Path=Width}"
Height="49" TextAlignment="Center" Foreground="Black"
Text="Avatar" Canvas.Left="10" Canvas.Top="53" FontSize="36"/>
<Ellipse xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="218" Width="266" Canvas.Top="152" Height="143" Name="ellipse2" Fill="#FFFF00FF" MouseDown="ellipse2_MouseDown"/>
<Ellipse xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="404" Width="266" Canvas.Top="300" Height="143" Name="ellipse3" Fill="#FFFF00FF" MouseDown="ellipse3_MouseDown"/>
</Canvas>
</Window>