Reputation: 65
I have this UserControl and I don't want it to be resizable. I have already set the max and mix width and height but it is still resizable. Is there any other way to block this properti on a UserControl? I know how to do it in a Window, but I cannot insert this control into a window, I would need to block the resize property just as it is.
<UserControl x:Class="Tanino.WPFPlayer.Views.OpenDiscView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="220.79" Width="543" MinHeight="220.79" MinWidth="543" MaxHeight="220.79" MaxWidth="543">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="13*"/>
<RowDefinition Height="auto" MinHeight="34"/>
<RowDefinition Height="auto" MinHeight="17"/>
<RowDefinition Height="23*"/>
<RowDefinition Height="auto" MinHeight="42"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Stretch" Margin="1, 5">
<RadioButton Content="DVD" x:Name="SelectedDvd" Margin="10,0"/>
<RadioButton Content="Bluray" x:Name="SelectedBluRay" Margin="10,0"/>
</StackPanel>
<Grid Grid.Row="2" Margin="1, 5">
<Separator HorizontalAlignment="Left" Height="3" Margin="15,0,15,0" VerticalAlignment="Top" Width="511"/>
</Grid>
<Grid Grid.Row="3" Margin="1,21,1,24">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Margin="5,0" Width="auto" Content="Disc Device"/>
<ComboBox Grid.Column="1" Margin="5,0" ItemsSource="{Binding ComboPaths}" SelectedItem="{Binding SelectedPath}"/>
<Button Grid.Column="2" Margin="5,0" Width="25" BorderThickness="1">
<Button.Background>
<ImageBrush ImageSource="resources/finder-toolbar-eject.png"/>
</Button.Background>
</Button>
<Button Grid.Column="3" HorizontalAlignment="Right" Margin="5,0" Content="Browse..." x:Name="SelectFolder"/>
</Grid>
<StackPanel Orientation="Horizontal" Grid.Row="4" HorizontalAlignment="Right" Margin="0,5,1,5" Width="170">
<Button Margin="5,10,5,0" Width="75" Content="Play" x:Name="Ok"/>
<Button Margin="5,10,5,0" Width="75" Content="Cancel" x:Name="Cancel"/>
</StackPanel>
<GroupBox Header="Disc Selection" HorizontalAlignment="Center" Margin="1,10,0,0" VerticalAlignment="Top" Height="149" Grid.RowSpan="4" Width="522">
<Image HorizontalAlignment="Left" Height="37" Margin="444,-3,0,0" VerticalAlignment="Top" Width="83" Source="resources/logo2.png"/>
</GroupBox>
</Grid>
Thanks in advance
Upvotes: 1
Views: 1679
Reputation: 1401
If you don't want to resize the control then don't use the auto
and *
in the grids inside. Use specific values.
Upvotes: 1
Reputation: 18789
Put your user control inside a window with
ResizeMode="NoResize"
<Window x:Class="MyEditor.Views.EditorWindow"
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"
xmlns:views="clr-namespace:Tanino.WPFPlayer.Views"
mc:Ignorable="d"
ResizeMode="NoResize"
Title="Editor Window">
<views:OpenDiscView />
</Window>
Upvotes: 1