현재 WPF 응용 프로그램의 레이아웃을 연구 중이며 컨트롤 중 하나의 레이아웃에 약간의 걸림돌이있는 것 같습니다. 이 컨트롤은 동적으로 크기가 조정되므로 뷰포트의 크기에 맞아야합니다. 내가 겪고있는 문제는 매우 시각적 인 문제이므로 그것을 설명하기 위해 최선을 다할 것입니다. 여기이 순간에 어떻게 표시되는지를 보여줍니다 :동적으로 WPF TextBlock 크기를 조정할 때 성능이 저하되었습니다.
alt text http://gallery.me.com/theplatz/100006/Capture/web.png?ver=12472534170001
은 "골 N 행 X"헤더의 각 아래 지역은 다양한 길이의 텍스트가 배치됩니다 TextBlock의입니다. 실제로 TextBlock을 감싸기 위해 텍스트 블록의 너비를 열의 너비에 바인딩하는 stackoverflow 솔루션을 발견했습니다. 여기에 그리드 정의의 조각은 첫 번째 열에 대한 정의와 함께입니다 : 창/뷰포트의 폭이 증가 할 때
<!-- Change Detail Contents Grid -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="270" Width="2*" />
<ColumnDefinition MinWidth="160" Width="*" />
<ColumnDefinition MinWidth="160" Width="*" />
<ColumnDefinition MinWidth="160" Width="*" />
</Grid.ColumnDefinitions>
<!--
We bind the width of the textblock to the width of this border to make sure things resize correctly.
It's important that the margin be set to 1 larger than the margin of the textblock or else you'll end
up in an infinate loop
-->
<Border Grid.Column="0" Margin="6" Name="FirstBorder" />
<Border Grid.Column="0" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource ColumnBorderBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Border Style="{DynamicResource DetailHeadingBorder}">
<TextBlock Text="Col 1 Row 1" Style="{DynamicResource DetailHeadingText}" />
</Border>
<TextBlock Text="{Binding IsReason, ElementName=ChangeDetailRoot}" Style="{DynamicResource DetailText}" Width="{Binding ActualWidth, ElementName=FirstBorder}" />
</StackPanel>
<StackPanel Grid.Row="1">
<Border Style="{DynamicResource DetailHeadingBorder}">
<TextBlock Text="Col 1 Row 2" Style="{DynamicResource DetailHeadingText}" />
</Border>
<TextBlock Text="{Binding WasReason, ElementName=ChangeDetailRoot}" Style="{DynamicResource DetailText}" Width="{Binding ActualWidth, ElementName=FirstBorder}" />
</StackPanel>
</Grid>
</Border>
</Grid>
모두 잘 크기를 조정합니다. 너비가 줄어들면 문제가 분명해진다. 갑자기 최대화에서 원래 크기로 이동하면 모든 열이 지정된 크기로 "춤"됩니다. 이것이 의미하는 바는 각 열의 크기를 줄이면 작은 크기로 다시 비례 적으로 크기가 조정됨을 볼 수 있다는 것입니다. 내가 발견 한 바로는 각각의 TextBlock에 직접
Width="{Binding ActualWidth, ElementName=FirstBorder}"
이 발생했기 때문입니다. 이 문제는 한 번에 더 많은 컨트롤이 화면에 표시 될 때 눈에 띄게 악화됩니다. 그러나이 줄이 없으면 각 TextBlock 내부의 텍스트가 오른쪽으로 계속 커지면서 열에 줄 바꿈하지 않고 더 많은 텍스트가 추가됩니다.
달성하려는 목표를 달성하는 더 좋은 방법이 있습니까? HTML/CSS를 사용하면 매우 간단하게 수행 할 수 있습니다. 인터넷 검색 및이 질문에 대한 답변 stackoverflow 통해 찾고 시간을 보냈습니다.
나는 HTML/CSS의 무거운 배경에서 왔기 때문에 이것이 WPF가 잘되어야하는 것이 아니라면 알려 주시기 바랍니다.
을 주제 가야하지,하지만 당신은 어디에서 찾았어요 그 아이콘들? 그들은 좋아 보인다. – FryGuy
http://famfamfam.com/lab/icons/silk/ Oxite 사이트를 탐색하면서 찾았습니다. http://www.visitmix.com/Lab/Oxite –
이것은 저에게 효과적입니다. 내 업데이트를 참조하십시오. – exclsr