2015-01-01 42 views
0

我有一個WPF窗口。 其XAML文件是建立在用戶控件標籤:我應該在哪裏更改c#WPF中的窗口大小?

<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" 
     > 

顯然,這不要緊,我改變寬度尺寸(1300在我的情況), 它不改變窗口大小。

如何更改我的窗口寬度?

+0

您的控件在開始時可能有一個''標籤。只要找到它,你就可以改變它的大小。 –

+0

不,它沒有標籤。它有一個標記,但沒有寬度屬性... – user1028741

+1

這樣看,沒有'Window'標記 - 沒有窗口。你的應用中有一個,只需在解決方案中查找。 –

回答

1

看來您的控件託管在另一個窗口中。 找到託管窗口並根據需要進行更改。

也許你可以嘗試Snoop來尋找父母windwo並玩其屬性來獲得你想要的產出。 Snoop on CodePlex

+0

傻了。我以爲我的xaml文件是窗口...... – user1028741

+0

所有時間都會發生......我強烈建議您使用** Snoop **或其他替代方法,它可以幫助我們找到像這樣的問題。新年快樂! – ShayD

0

如果我理解正確的話,你的XAML大概是這樣的:

<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> 

因此,要改變寬度和用戶控件的高度,您可以通過在「網格」將行或列做。