最近我在我的模板中添加了新行,对我来说似乎一切都很好,但由于某种原因,我的隐藏面板开始表现得很尴尬。小组应该在中心。它出现在动画之后。 我注意到在添加RowDefinition Height =" 40" />后开始出现问题,但我并不清楚究竟出了什么问题以及它应该如何。请帮帮我。
<Grid Margin="0,80,0,0" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" x:Name="textBlock" HorizontalAlignment="Center" VerticalAlignment="Center" Height="40" Margin="0,10,0,10" TextWrapping="Wrap" Text="{Binding Path=Controller.LegViewModel.Title}" FontSize="28"/>
<ContentControl Grid.Row="1" Content="{Binding Controller.LegViewModel}" VerticalAlignment="Center" Margin="0,10,0,10" ContentTemplateSelector="{StaticResource LegTemplateSelector}" Background="#FFF7F7F7"/>
<ListView Grid.Row="2" ItemsSource="{Binding Path=Controller.LegViewModel.LegSections}" Margin="5,10,5,10" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<!--<ContentControl Content="{Binding}" ContentTemplateSelector="{StaticResource LegTemplateSelector}" Background="#FFF7F7F7" Grid.ColumnSpan="2"/>-->
<ContentPresenter ContentTemplate="{StaticResource StandartPartTemplate}" Grid.ColumnSpan="2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<!--<ContentControl ContentTemplateSelector="{StaticResource LegTemplateSelector}" Background="#FFF7F7F7" Grid.ColumnSpan="2"/>-->
</ListView>
<!--<ContentControl Content="{Binding Controller.LegViewModel}" ContentTemplateSelector="{StaticResource LegTemplateSelector}" Background="#FFF7F7F7" Grid.ColumnSpan="2"/>-->
<StackPanel Orientation="Horizontal" Grid.Row="3" VerticalAlignment="Center">
<Button x:Name="AddButton" Command="{Binding RevertCommand}" Content="Вернуться к ноге" HorizontalAlignment="Left" VerticalAlignment="Top" Width="408" Background="#FFDBEDF7" FontSize="16" Grid.ColumnSpan="2"/>
<Button x:Name="AddButton_Copy" Command="{Binding SaveCommand}" Content="Сохранить" HorizontalAlignment="Right" VerticalAlignment="Top" Width="408" Background="#FFDBEDF7" FontSize="16" Grid.ColumnSpan="2"/>
<Button x:Name="AddButton2" Content="Сохранить" HorizontalAlignment="Right" VerticalAlignment="Top" Width="408" Background="#FFDBEDF7" FontSize="16" Grid.ColumnSpan="2"/>
</StackPanel>
<Border Visibility="{Binding PanelOpened, Converter={StaticResource BoolToVis}}" x:Name="ShadowOverlay">
<Border.Background>
<SolidColorBrush Color="Black" Opacity="0.78"/>
</Border.Background>
</Border>
<Border x:Name="panelControl" Margin="0,0,-450,0" VerticalAlignment="Stretch" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5" Width="450" Height="275" DataContext="{Binding CurrentPanelViewModel}" >
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
<Grid>
<Canvas Background="#FFC6E8E6">
<TextBlock x:Name="textBlock7" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Canvas.Left="135" FontSize="14" Canvas.Top="4"><Run Text="Добавить сво"/><Run Text="ё описание"/><Run Text=" "/><Run Text=" "/></TextBlock>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="43" TextWrapping="Wrap" Text="{Binding Path=Text1}" VerticalAlignment="Top" Width="422" Canvas.Left="10" Canvas.Top="61" />
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="43" TextWrapping="Wrap" Text="{Binding Path=Text2}" VerticalAlignment="Top" Width="422" Canvas.Left="10" Canvas.Top="173"/>
<CheckBox x:Name="checkBox" Content="есть поле для размерности" HorizontalAlignment="Left" IsChecked="{Binding Path=HasSize}" VerticalAlignment="Top" Canvas.Left="10" Canvas.Top="109"/>
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="233" ItemsSource="{Binding Path=Dimentions}" Visibility="{Binding Path=HasSize, Converter={StaticResource BoolToVis}}" SelectedItem="{Binding SelectedItem}" Canvas.Left="199" Canvas.Top="113" Height="23"/>
<Button x:Name="button" Content="Отмена" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Canvas.Left="53" Canvas.Top="232"/>
<Button x:Name="button_Copy" Content="Добавить" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Command="{Binding AddCommand}" Canvas.Left="249" Canvas.Top="232"/>
<Separator Height="18" Margin="0" Canvas.Top="19" Width="442"/>
<TextBlock x:Name="textBlock_Copy" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Canvas.Top="37" Canvas.Left="10" Text="Первая часть:"/>
<TextBlock x:Name="textBlock_Copy1" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Canvas.Top="152" Canvas.Left="10"><Run Text="Вторая часть "/><Run Text="(не обязательно к заполнению):"/></TextBlock>
<CheckBox x:Name="checkBox_Copy" Content="двойная размерность (х*х)" Visibility="{Binding Path=DoubleSizeAvailable, Converter={StaticResource BoolToVis}}" HorizontalAlignment="Left" IsChecked="{Binding HasSize}" VerticalAlignment="Top" Canvas.Left="10" Canvas.Top="132"/>
</Canvas>
</Grid>
</Border>
<Grid.Triggers>
<EventTrigger RoutedEvent="Button.Click" SourceName="AddButton2">
<BeginStoryboard Name="MyBeginStoryboard">
<Storyboard TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" local1:StoryboardHelper.CompletedCommand="{Binding Path=OpenPanelCommand}">
<DoubleAnimation
Storyboard.TargetName="panelControl"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
Duration="0:0:005" From="0" To="-700" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
答案 0 :(得分:0)
您的“面板”(名为panelControl的边框)是您要为其创建新行的Grid的子节点。
如果您没有说明Grid的子行在哪一行,则子项所在的默认行是第一行(索引0)。如果我们谈论Grid的专栏,情况也是如此。在你的情况下,你的第一行是高度为40的那一行。子控件的边距将相对于那个单元格(第0列,第0行)
如果您希望您的孩子占用所有可用空间,只需设置其RowSpan,如下所示:
<Border x:Name="panelControl" Grid.RowSpan="4" Margin="0,0,-450,0" VerticalAlignment="Stretch" HorizontalAlignment="Right" RenderTransformOrigin="0.5,0.5" Width="450" Height="275" DataContext="{Binding CurrentPanelViewModel}" >
或者,您可以将Grid和Border放在另一个Grid中,包含1行和1列。这样,原始网格和名为“panelControl”的边框就会相互重叠。
<Grid> //This is your new Grid
<Grid> //This is your original grid
....
</Grid>
<Border x:Name="panelControl" .../> //This is your Border
</Grid>