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?

有帮助吗?

解决方案

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.

其他提示

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top