我有一个用户控件,它有一个网格作为根元素。我想在我的控制下弹出一个提供额外信息的调用框。我遇到的问题是标注的高度和宽度与网格大小相关联。使控件非常小会缩小调用框。如何使标注大小更适合文本内容?
这是用户控件
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
mc:Ignorable="d"
x:Class="WpfUserControlsTest.Door"
x:Name="UserControl"
d:DesignWidth="86" d:DesignHeight="19">
<Grid x:Name="LayoutRoot">
<Rectangle Fill="Red"/>
<ed:Callout AnchorPoint="-0.012,1.349" CalloutStyle="RoundedRectangle" Content="Callout text in here" Fill="#FFF4F4F5" FontSize="14.667" HorizontalAlignment="Left" Height="53" Margin="91,-72,-167,0" Stroke="Black" VerticalAlignment="Top" Width="162"/>
</Grid>
在这里使用
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfUserControlsTest" x:Class="WpfUserControlsTest.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Canvas>
<local:Door HorizontalAlignment="Left" Height="9" VerticalAlignment="Top" Width="23.333" Canvas.Left="28.666" Canvas.Top="83.333" />
</Canvas>
</Grid>
这是结果