3

I have Usercontrol.I want to disable its resizing. The usercontrol is:

<UserControl x:Class="DocumentUpload"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
      xmlns:telerikGrid1="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
      xmlns:telerikInp="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
      xmlns:telerikNav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
      xmlns:telerikData="clr-namespace:Telerik.Windows.Data;assembly=Telerik.Windows.Data" 
      xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       Height="auto" Width="auto" MaxWidth="520">

I got to know that there is property called

ResizeMode="NoResize"

.But it is not available in UserControl.Any suugestion?

UserK
  • 33
  • 1
  • 3
  • How about setting property of the Window where you put UserControl to `ResizeMode="NoResize"`, or set the Height and Width to fixed value instead of Auto? What do you mean by resizing user control, user control is not resizeable by default isn't it? – har07 Jan 23 '14 at 11:09
  • no it is used as a popup message.It is displayed and everything else is grayedout. – UserK Jan 23 '14 at 11:18
  • how you display the popup message, by creating a window to host your user control? I mean about like shown [here](http://stackoverflow.com/a/1262128/2998271)? if yes, you can set the window's property as I stated above. Otherwise you need to tell us how you display the popup, since I don't have any further idea without knowing that – har07 Jan 23 '14 at 11:22

2 Answers2

3

You have Width and Height set to Auto, so I guess you want to allow the control to take as much space as needed but not more.

Also, UserControl is not resizing by itself, but depends upon the layout that it's part of.

So, the quickest way to fix your issue would be to set HorizontalAlignment="Left" and VerticalAlignment="Top". But you should consider the whole layout of your application and how the UC is affected by-/affects on other components of the UI.

XAMeLi
  • 6,189
  • 2
  • 22
  • 29
  • Yeah it is appearing at top left corner.But when it appears user can resize this user control by dragging the resize arrow which appears on the User Control's border.I want User not to resize it. – UserK Jan 23 '14 at 11:21
  • Did you set horizontal/vertical alignment? Also, user control doesn't include the resize arrow, how are you using/consuming this user control? – XAMeLi Jan 23 '14 at 11:57
  • This user control is displayed inside RAD Window.Let me set the property there.Thanks I got my answer. – UserK Jan 23 '14 at 13:21
1

Then the Parent property of your UserControl is holding the Window instance. Most of times, it will be NavigationWindow. Try the below code in loaded event of your UserControl and it will work.

((NavigationWindow)this.Parent).ResizeMode = ResizeMode.NoResize
Jawahar
  • 4,775
  • 1
  • 24
  • 47