2013-07-22 24 views
0

我有一個用戶控件,它有一個網格作爲根元素。 我想在我的控制下彈出一個呼叫框,以提供額外的信息。 我遇到的問題是呼出的高度和寬度與網格大小有關。 使控制非常小縮小呼叫框。 如何將標註尺寸設置爲文本內容的大小?Wpf表達式調出剪輯

這裏是該用戶控件

<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> 

下面是結果 Here is the clipped callout

+0

首先請刪除寬度=「162」爲ed:標註。 – Nitesh

回答

0

在WPF中,設置明確的Height和/或Width尺寸和/或Margin s將停止UserControl自己的尺寸。如果您希望UserControl根據其內容大小重新調整大小,只需刪除您設置的顯式佈局和維度值即可。

+0

感謝您的期待,但這不是我想要的。如果我這樣做了,那麼這個呼出框就沒有大小或位置。 – Kaya

+0

它只有沒有大小,如果它沒有內容,並且位置與大小無關...設置位置不會影響大小。一切都一樣,適合你自己。 :) – Sheridan