user1028741
user1028741

Reputation: 2825

Where should I change the window size in c# WPF?

I have a WPF window. its xaml file is built of a UserControl tag:

<UserControl x:Class="DeploymentTool.View.ToolPanelMappingView"
         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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
         xmlns:sys="clr-namespace:System;assembly=mscorlib"
         ...
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="1300"
         >

Apparently it doesn't matter what I change the width size to (1300 in my case), it doesn't change the window size.

How can I change my window's width?

Upvotes: 0

Views: 146

Answers (2)

ShayD
ShayD

Reputation: 930

It seems that your control is hosted inside another window. Find the hosting window and change it as you wish.

Maybe you can try Snoop to fin the parent windwo and play with its properties to get the layput you want. Snoop on CodePlex

Upvotes: 1

StepUp
StepUp

Reputation: 38209

If I understand correctly, your xaml probably is like this:

<Window x:Class="WpfApplication1.SomeWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SomeWindow" Height="700" Width="1300">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="2*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="2*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <UserControl            
        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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
     xmlns:sys="clr-namespace:System;assembly=mscorlib"         
     mc:Ignorable="d" 
     d:DesignHeight="300" d:DesignWidth="30" Background="Green" Grid.Column="1" Grid.Row="1"></UserControl>

</Grid>

So to change width and height of UserControl, you can do it by adding rows or columns in the 'Grid'.

Upvotes: 0

Related Questions