2016-12-12 1 views
0

내 WPF 응용 프로그램 중 하나의 창에서 단추의 너비를 더 작은 크기로 변경할 수 없습니다. xaml에서 "width"속성을 변경하거나 디자이너에서 단추를 드래그하거나 C#을 사용하여 실용적인 방법으로 변경했습니다. 창에서 새 버튼을 만들었더라도 폭은 더 큰 크기로만 변경할 수 있지만 더 작은 크기로는 변경할 수 없습니다. 오류나 경고가 없었지만 접근 방식 중 어느 것도 폭을 성공적으로 변경하지 못했습니다. 이상한 것은 드래그하여 단추의 높이를 쉽게 또는 더 크게 변경할 수 있었고, 다른 창에서는 버튼의 너비와 높이를 더 쉽게 또는 더 크게 변경할 수있었습니다. 모든 창에서 모든 버튼에 동일한 스타일을 사용하고 있습니다. 내가 버튼을 드래그하면 내가 주변이 Litlle "매듭"의 하나의 잠금을 해제하지 않는 한, 그것의 응답이 없을 것이다, 그러나 그것은 다음과 같이 표시됩니다WPF : 단추 너비를 더 작게 변경할 수 없습니다.

enter image description here

유일한 것은 내가 사용하는 것입니다 이 창에 대한 알림 템플릿 및 애니메이션 효과가 있습니다. 그러나 나는 다른 사람들과 큰 차이를 보지 못했다.

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

그것에 대해 생각을합니까 : 여기 XAML 코드는? 미리 감사드립니다!

답변

1

아이디어가 있습니까?

당신은 당신은 분명 사용하고있는 사용자 정의 스타일의 마크 업을 게시하는 것을 잊었다하지만 당신은 0으로 버튼의 최소 폭 속성을 설정을 시도 할 수 있습니다 :

<Button x:Name="button1" Content="OK" Margin="358,341,13,72" Click="Submit_Click" FontSize="16" 
      VerticalAlignment="Top" HorizontalAlignment="Left" MinWidth="0"/> 

당신의 모든 게시하시기 바랍니다 여전히 XAML 태그의 너비를 늘릴 수없는 경우 XAML 태그 및 코드의 일부를 관련시킵니다.

+0

네 도움이됩니다. 정말 고맙습니다! – Lolo

관련 문제