간단한 창 :App.xaml에서 Grid.Margin이 설정된 경우 TextBox에서 패딩이 발생하는 이유는 무엇입니까?
<Window x:Class="MyApp.MainWindow" xmlns="..." xmlns:x="...">
<Window.Resources>
<Style TargetType="Grid">
<Setter Property="Margin" Value="8"/>
</Style>
</Window.Resources>
<Grid>
<TextBox VerticalAlignment="Top" HorizontalAlignment="Left">Test</TextBox>
</Grid>
</Window>
은 다음과 같습니다
이제 우리는Window.Resources
제거 :
<Window x:Class="MyApp.MainWindow" xmlns="..." xmlns:x="...">
<Grid>
<TextBox VerticalAlignment="Top" HorizontalAlignment="Left">Test</TextBox>
</Grid>
</Window>
을 그리고 App.xaml
에 스타일 정의를 추가 :
이유 :
<Application x:Class="MyApp.App" xmlns="..." xmlns:x="..." StartupUri="View\MainWindow.xaml">
<Application.Resources>
<Style TargetType="Grid">
<Setter Property="Margin" Value="8"/>
</Style>
</Application.Resources>
</Application>
이상하게도, 텍스트 상자는 이제 패딩을 얻는다?
+1 너무 나쁘다고 나는 이것을 실현하지 못했습니다. – loxxy
@loxxy - 그래, 아직 미묘한 뉘앙스에 대한 문서를 찾지 못했습니다. – CodeNaked
음, 고마워요! 그래서 이것을 피하는 가장 좋은 방법은 무엇입니까? 사전을 별도의 파일에 넣으시겠습니까? Grid 및 Panel에 대한 스타일을 설정하지 마십시오. –