Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ItemsControl Name="Items"
- ItemsSource="{Binding Parameters}">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Horizontal"/>
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- <ItemsControl.Resources>
- <DataTemplate DataType="{x:Type grace:Present}">
- <local:PresentView Width="{Binding ActualWidth, ElementName=Items}"/>
- </DataTemplate>
- <DataTemplate DataType="{x:Type grace:RelayCfg}">
- <local:RelayCfgView Margin="0 2 2 0"/>
- </DataTemplate>
- </ItemsControl.Resources>
- </ItemsControl>
- <UserControl.Resources>
- <Style TargetType="{x:Type Border}">
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="BorderBrush" Value="{StaticResource MainBrush60}"/>
- <Setter Property="BorderThickness" Value="1"/>
- </Style>
- <Style x:Key="MainName"
- TargetType="{x:Type TextBlock}">
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="FontSize" Value="18"/>
- <Setter Property="Foreground" Value="{StaticResource BaseBrush}"/>
- </Style>
- </UserControl.Resources>
- <Border>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="auto"/>
- <RowDefinition/>
- </Grid.RowDefinitions>
- <Border Grid.Row="0"
- Background="{StaticResource MainBrush60}">
- <TextBlock Style="{StaticResource MainName}"
- Text="{Binding Name}"/>
- </Border>
- <ItemsControl Grid.Row="1"
- Margin="5"
- ItemsSource="{Binding Properties}">
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Vertical"/>
- </ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- <ItemsControl.Resources>
- <DataTemplate DataType="{x:Type grace:ByteProperty}">
- <local:BytePropertyView/>
- </DataTemplate>
- </ItemsControl.Resources>
- </ItemsControl>
- </Grid>
- </Border>
- protected override Size MeasureOverride(Size constraint)
- {
- // Берем корневой элемент (в данном случае это Border)
- var child = (FrameworkElement)Content;
- // Командуем ему рассчитать необходимое место
- child.Measure(constraint);
- // Говорим опрашивающему нас контролу что нам нужна вся
- // доступная ширина и высота, которую "заказал" дочерний контрол
- return new Size(constraint.Width, child.DesiredSize.Height);
- }
Add Comment
Please, Sign In to add comment