Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resize the user control in wpf at runtime

Am newbie to wpf development.In my wpf app i used user control.what i need is in runtime how can resize the user control,

Please help me to find solution,if my approach is wrong please guide me to get solution,

My XAML code is

<UserControl x:Class="test.pad"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Focusable="True" OverridesDefaultStyle="False">

    <Grid Width="102" Height="123" Name="Grid1" MouseMove="Grid1_MouseMove" MouseUp="Grid1_MouseUp" MouseDown="Grid1_MouseDown">
        <Grid.RenderTransform>
            <TranslateTransform x:Name="tt"/>
        </Grid.RenderTransform>

        <Border BorderBrush="Silver" BorderThickness="2">

            <Canvas Height="120" HorizontalAlignment="Left" Margin="0,1,0,0" Name="canvas1" VerticalAlignment="Top" Width="100" Grid.ColumnSpan="2">
                <RichTextBox Height="98" HorizontalAlignment="Left" Margin="0,24,0,0" Name="richTextBox1" VerticalAlignment="Top" Width="100" BorderThickness="2" Grid.ColumnSpan="2" Background="#FFFF96D8" Canvas.Top="-3" Canvas.Left="-1" />
                <Button BorderBrush="#FFFF96D8" Canvas.Left="46" Canvas.Top="-2" Height="23" Name="close" Width="27">

                </Button>
                <Button Height="23" Name="minimise" Width="27" BorderBrush="#FFFF96D8" Click="button1_Click" Canvas.Left="72" Canvas.Top="-2" ClipToBounds="False" IsEnabled="True" IsHitTestVisible="True" OverridesDefaultStyle="False" ForceCursor="False" Foreground="Black" MouseMove="button1_MouseEnter" MouseLeave="button1_MouseLeave">

            </Canvas>

        </Border>

    </Grid>
</UserControl>

thanks ash

like image 543
Ash Avatar asked Nov 14 '22 20:11

Ash


1 Answers

Remove the Height and Width of the UserControl and also the Grid.
Set the Margin or Size Property for UserControl where you call it.

like image 55
Binil Avatar answered Nov 24 '22 00:11

Binil