質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

Q&A

解決済

2回答

2362閲覧

【WPF】コントロールのサイズをウィンドウサイズに合わせたサイズで表示させたい

退会済みユーザー

退会済みユーザー

総合スコア0

XAML

XAML(Extensible Application Markup Language)はWPF、Silverlight、Windows PhoneそしてWindows Store appsでユーザーインターフェースを定義するために使われるXML言語です。

WPF

Windows Presentation Foundation (WPF) は、魅力的な外観のユーザー エクスペリエンスを持つ Windows クライアント アプリケーションを作成するための次世代プレゼンテーション システムです

0グッド

0クリップ

投稿2021/04/17 02:25

前提・実現したいこと

・GroupBoxとGridのサイズをウィンドウサイズに合わせたサイズに変更したいのですが実際のサイズがちいさくなってしまい悩んでいます。
Height="*"とするとエラーになり、Height="Auto"にしてもウィンドウサイズよりも小さいサイズとなってしまいます。

指定の方法を教えてください。

該当のソースコード

xmal

1<Window 2 x:Class="Test.Views.MainWindow" 3 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 4 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 5 xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors" 6 xmlns:l="http://schemas.livet-mvvm.net/2011/wpf" 7 xmlns:v="clr-namespace:Test.Views" 8 xmlns:vm="clr-namespace:Test.ViewModels" 9 Title="MainWindow" 10 Width="1000" 11 Height="800"> 12 13 <Window.DataContext> 14 <vm:MainWindowViewModel /> 15 </Window.DataContext> 16 17 18 <behaviors:Interaction.Triggers> 19 <!-- When ContentRendered event raised, Initialize method of ViewModel would be called. --> 20 <behaviors:EventTrigger EventName="ContentRendered"> 21 <l:LivetCallMethodAction MethodName="Initialize" MethodTarget="{Binding}" /> 22 </behaviors:EventTrigger> 23 24 <!-- Dispose method is called, when Window closing. --> 25 <behaviors:EventTrigger EventName="Closed"> 26 <l:DataContextDisposeAction /> 27 </behaviors:EventTrigger> 28 29 <!-- If you make user choose 'OK or Cancel' closing Window, then please use Window Close cancel Behavior. --> 30 31 </behaviors:Interaction.Triggers> 32 33 <Grid> 34 <GroupBox x:Name="CalendarGropu1" 35 Header="" 36 HorizontalAlignment="Left" 37 Height="300" 38 Margin="10,10,0,0" 39 VerticalAlignment="Top" 40 Width="497" 41 Style="{StaticResource gp-normal}" > 42 43 44 <Grid x:Name="CalendarGrid" 45 HorizontalAlignment="Left" 46 Height="258" 47 Margin="10,10,0,0" 48 VerticalAlignment="Top" 49 Width="467" 50 > 51 52 53 <Grid.ColumnDefinitions> 54 <ColumnDefinition Width="1*" /> 55 <ColumnDefinition Width="1*" /> 56 <ColumnDefinition Width="1*" /> 57 <ColumnDefinition Width="1*" /> 58 <ColumnDefinition Width="1*" /> 59 <ColumnDefinition Width="1*" /> 60 <ColumnDefinition Width="1*" /> 61 </Grid.ColumnDefinitions> 62 63 <Grid.RowDefinitions> 64 <RowDefinition Height="20" /> 65 <RowDefinition Height="1*" /> 66 <RowDefinition Height="1*" /> 67 <RowDefinition Height="1*" /> 68 <RowDefinition Height="1*" /> 69 <RowDefinition Height="1*" /> 70 </Grid.RowDefinitions> 71 </Grid> 72 </GroupBox> 73 74 </Grid> 75</Window>

補足情報(FW/ツールのバージョンなど)

VisualStudio2019
.Net Core3.0
Livet v3.2.1

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

どうなればいいのかちょっとわかりませんが、基本的にサイズは入れません(Auto状態)
AlignmentStretch以外は、中のコンテンツに合わそうとするので広がりません。

xml

1<Window 2 x:Class="Questions333670.MainWindow" 3 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 4 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 5 Width="1000" 6 Height="800"> 7 8 <Grid> 9 <Grid.RowDefinitions> 10 <RowDefinition /> 11 <RowDefinition /> 12 </Grid.RowDefinitions> 13 <Grid.ColumnDefinitions> 14 <ColumnDefinition /> 15 <ColumnDefinition /> 16 </Grid.ColumnDefinitions> 17 18 <GroupBox Margin="10"> 19 <Grid Margin="10" ShowGridLines="True"> 20 <Grid.ColumnDefinitions> 21 <ColumnDefinition /> 22 <ColumnDefinition /> 23 <ColumnDefinition /> 24 <ColumnDefinition /> 25 <ColumnDefinition /> 26 <ColumnDefinition /> 27 <ColumnDefinition /> 28 </Grid.ColumnDefinitions> 29 <Grid.RowDefinitions> 30 <RowDefinition Height="20" /> 31 <RowDefinition /> 32 <RowDefinition /> 33 <RowDefinition /> 34 <RowDefinition /> 35 <RowDefinition /> 36 </Grid.RowDefinitions> 37 </Grid> 38 </GroupBox> 39 40 <GroupBox Grid.Column="1" Margin="10"> 41 <DockPanel Margin="10"> 42 <UniformGrid Columns="7" DockPanel.Dock="Top"> 43 <TextBlock HorizontalAlignment="Center" Text="" /> 44 <TextBlock HorizontalAlignment="Center" Text="" /> 45 <TextBlock HorizontalAlignment="Center" Text="" /> 46 <TextBlock HorizontalAlignment="Center" Text="" /> 47 <TextBlock HorizontalAlignment="Center" Text="" /> 48 <TextBlock HorizontalAlignment="Center" Text="" /> 49 <TextBlock HorizontalAlignment="Center" Text="" /> 50 </UniformGrid> 51 <UniformGrid Columns="7" Rows="5"> 52 <Rectangle Fill="Pink" /> 53 </UniformGrid> 54 </DockPanel> 55 </GroupBox> 56 </Grid> 57</Window>

投稿2021/04/17 04:15

編集2023/07/26 15:58
TN8001

総合スコア9304

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

ベストアンサー

HorizontalAlignment="Left"
VerticalAlignment="Top"

Width と Height を消して、上記2つの値を、

Stretch
親要素のレイアウト スロット全体に引き伸ばして配置された要素。

にしたらどうなりますか?

投稿2021/04/17 04:13

nfox

総合スコア229

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/04/18 05:48

ありがとうございます。 望んでいた表示になりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問