私のWPFアプリケーションのウィンドウの1つでは、ボタンの幅を自分のサイズに合わせて小さく変更することはできません。私はxamlの "width"のプロパティを変更しようとしました。デザイナーのボタンをドラッグするか、C#を使って実際に変更しました。そのウィンドウ内に新しいボタンを作成したとしても、その幅はより大きなサイズに変更できますが、より小さなサイズに変更することはできませんでした。エラーや警告はありませんでしたが、いずれのアプローチも幅をうまく変更できませんでした。変わったことは、ボタンの高さをドラッグで簡単に小さくまたは大きく変更でき、他のウィンドウではボタンの幅と高さを簡単に小さくまたは大きく変更できます。私はすべてのウィンドウのすべてのボタンに同じスタイルを使用しています。私は、ボタンをドラッグした場合、私はそれのまわりlitlle「結び目」の1のロックを解除しない限り、それが何の応答もないだろうが、それは次のようになります。WPF:ボタンの幅を小さく変更することはできません
唯一のことは、私が使用していることですこのウィンドウの通知テンプレートといくつかのアニメーション効果があります。しかし、私はそれと他の人との間に大きな違いは見られませんでした。ここでXAMLコードは次のとおりです。
<Window x:Class="Timebreak.NotiWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Timebreak"
mc:Ignorable="d"
Title="TimeBreak" Height="450" Width="450"
WindowStyle="None" AllowsTransparency="True" Opacity="0.7" Background="#f9f9ff"
WindowStartupLocation="Manual" Left="0" Top="0">
<Grid>
<Button x:Name="button1" Content="OK" Margin="358,341,13,72" Click="Submit_Click" FontSize="16" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<RadioButton x:Name="radioButton" Content="Yes. I want to stand up and take a break for (minutes)" HorizontalAlignment="Left" Height="26" Margin="31,105,0,0" VerticalAlignment="Top" Width="368" Checked="radioButton_Checked" FontSize="14"/>
<RadioButton x:Name="radioButton1" Content="No. I don't want to stand up and take a break because" HorizontalAlignment="Left" Margin="31,206,0,0" VerticalAlignment="Top" FontSize="14" Checked="radioButton1_Checked"/>
<Slider x:Name="slider" HorizontalAlignment="Left" Height="23" Margin="40,136,0,0" VerticalAlignment="Top" Width="374" IsSnapToTickEnabled="True" ValueChanged="slider_ValueChanged" Maximum="30" Minimum="1" Cursor="Hand" AutoToolTipPlacement="TopLeft" Interval="29" IsMoveToPointEnabled="True" TickPlacement="BottomRight"/>
<!-- Animation -->
<Grid.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="0:0:2" Value="1"/>
<SplineDoubleKeyFrame KeyTime="0:0:4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.RenderTransform>
<ScaleTransform ScaleY="1" />
</Grid.RenderTransform>
</Grid>
はそれについて考えをしていますか?前もって感謝します!
はい、役立ちます。どうもありがとうございます! – Lolo