I have a popup in a user control. A popup window uses a TextBox to display a textual preview of the data generated by the control.
How to make the size of the popup window the user controlling it inside? With the code as shown below, I found that the text field is sized according to its contents, and the pop-up window is sized according to the text field.
It works fine if I use fixed sizes in row and column definitions, but I would like to pop up to resize it to fit the user control (which in turn matches the browser).
<UserControl
<!-- usual stuff here -->
>
<Grid>
<Popup Name="MyPopup">
<Border BorderBrush="Black" BorderThickness="2" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Preview:" Margin="5" ></TextBlock>
<TextBox
Grid.Row="1"
Name="MyTextBox"
IsReadOnly="True"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible"
TextWrapping="Wrap"
Margin="5"
>
</TextBox>
</Grid>
</Border>
</Popup>
</Grid></UserControl>