Guest User

Untitled

a guest
Jul 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. <ItemsControl Name="Items"
  2. ItemsSource="{Binding Parameters}">
  3. <ItemsControl.ItemsPanel>
  4. <ItemsPanelTemplate>
  5. <WrapPanel Orientation="Horizontal"/>
  6. </ItemsPanelTemplate>
  7. </ItemsControl.ItemsPanel>
  8. <ItemsControl.Resources>
  9. <DataTemplate DataType="{x:Type grace:Present}">
  10. <local:PresentView Width="{Binding ActualWidth, ElementName=Items}"/>
  11. </DataTemplate>
  12. <DataTemplate DataType="{x:Type grace:RelayCfg}">
  13. <local:RelayCfgView Margin="0 2 2 0"/>
  14. </DataTemplate>
  15. </ItemsControl.Resources>
  16. </ItemsControl>
  17.  
  18. <UserControl.Resources>
  19. <Style TargetType="{x:Type Border}">
  20. <Setter Property="SnapsToDevicePixels" Value="True"/>
  21. <Setter Property="BorderBrush" Value="{StaticResource MainBrush60}"/>
  22. <Setter Property="BorderThickness" Value="1"/>
  23. </Style>
  24. <Style x:Key="MainName"
  25. TargetType="{x:Type TextBlock}">
  26. <Setter Property="SnapsToDevicePixels" Value="True"/>
  27. <Setter Property="FontSize" Value="18"/>
  28. <Setter Property="Foreground" Value="{StaticResource BaseBrush}"/>
  29. </Style>
  30. </UserControl.Resources>
  31.  
  32. <Border>
  33. <Grid>
  34. <Grid.RowDefinitions>
  35. <RowDefinition Height="auto"/>
  36. <RowDefinition/>
  37. </Grid.RowDefinitions>
  38. <Border Grid.Row="0"
  39. Background="{StaticResource MainBrush60}">
  40. <TextBlock Style="{StaticResource MainName}"
  41. Text="{Binding Name}"/>
  42. </Border>
  43. <ItemsControl Grid.Row="1"
  44. Margin="5"
  45. ItemsSource="{Binding Properties}">
  46. <ItemsControl.ItemsPanel>
  47. <ItemsPanelTemplate>
  48. <WrapPanel Orientation="Vertical"/>
  49. </ItemsPanelTemplate>
  50. </ItemsControl.ItemsPanel>
  51. <ItemsControl.Resources>
  52. <DataTemplate DataType="{x:Type grace:ByteProperty}">
  53. <local:BytePropertyView/>
  54. </DataTemplate>
  55. </ItemsControl.Resources>
  56. </ItemsControl>
  57. </Grid>
  58. </Border>
  59.  
  60. protected override Size MeasureOverride(Size constraint)
  61. {
  62. // Берем корневой элемент (в данном случае это Border)
  63. var child = (FrameworkElement)Content;
  64. // Командуем ему рассчитать необходимое место
  65. child.Measure(constraint);
  66. // Говорим опрашивающему нас контролу что нам нужна вся
  67. // доступная ширина и высота, которую "заказал" дочерний контрол
  68. return new Size(constraint.Width, child.DesiredSize.Height);
  69. }
Add Comment
Please, Sign In to add comment