我想看看我的设计是在扩展器XAML中

时间:2016-05-13 13:16:43

标签: c# wpf xaml mvvm

如何在设计视图中看到我的设计 扩展器?我用的是VS2015。

<Grid Grid.Row="2" Height="30" Background="{StaticResource HeaderBackground}" Margin="5">
        <TextBlock Foreground="{StaticResource HeaderText}" Text="Old Events" FontSize="15" Margin="10,0,0,0" />


        <Expander HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  IsExpanded="True"
                  ExpandDirection="Down"
                  FlowDirection="RightToLeft">

            <Grid FlowDirection="LeftToRight">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" Margin="5,0,5,0" Grid.IsSharedSizeScope="True">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions >
                        <ColumnDefinition Width="6"" />
                        <ColumnDefinition Width="56"/>
                        <ColumnDefinition Width="18"/>
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="150" />
                        <ColumnDefinition Width="106" />
                    </Grid.ColumnDefinitions>
                    <Grid.Resources>
                        <Style TargetType="TextBlock">
                            <Setter Property="FontSize" Value="15"/>
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Setter Property="HorizontalAlignment" Value="Left"/>
                            <Setter Property="VerticalAlignment" Value="Center"/>
                            <Setter Property="Margin" Value="0,0,0,2"/>
                        </Style>
                    </Grid.Resources>
                    <TextBlock Grid.Column="0" Text="Id" Margin="0,4,0,6" Grid.ColumnSpan="2"/>
                    <TextBlock Grid.Row="0" Grid.Column="3" Text="Event" Margin="0,4,0,6"/>
                    <TextBlock Grid.Row="0" Grid.Column="4" Text="Namn" Margin="0,4,0,6"/>
                    <TextBlock Grid.Row="0" Grid.Column="5" Text="Tidpunkt" Margin="0,4,0,6"/>
                    <Border Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="6" BorderThickness="0,0,0,1" BorderBrush="Black"/>

                    <ListView Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="1" x:Name="OldEventsListView" Style="{x:Null}" ItemsSource="{Binding NotificationEvents}" BorderThickness="0" Width="488" Height="150" HorizontalAlignment="Left" Margin="0,0,-2,-150" Grid.RowSpan="2">
                        <ListView.Resources>
                            <DataTemplate DataType="{x:Type local:NotificationEventViewModel+NotificationEvent}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition SharedSizeGroup="A" />
                                        <ColumnDefinition SharedSizeGroup="B" />
                                        <ColumnDefinition SharedSizeGroup="B"/>
                                        <ColumnDefinition SharedSizeGroup="C"/>
                                    </Grid.ColumnDefinitions>

                                    <Grid.Resources>
                                        <Style TargetType="TextBlock">
                                            <Setter Property="Height" Value="30"/>
                                            <Setter Property="HorizontalAlignment" Value="Left"/>
                                            <Setter Property="VerticalAlignment" Value="Center"/>
                                        </Style>
                                    </Grid.Resources>
                                    <Border BorderThickness="0,0,0,1" BorderBrush="LightGray" Grid.ColumnSpan="4" Margin="0,5,0,5" />
                                    <TextBlock Grid.Column="0" Text="{Binding Id}" />
                                    <TextBlock Grid.Column="1" Text="{Binding Event}"/>
                                    <TextBlock Grid.Column="2" Text="{Binding Name}"/>
                                    <TextBlock Grid.Column="3" Text="{Binding TimeStamp}"/>
                                </Grid>
                            </DataTemplate>
                        </ListView.Resources>
                    </ListView>
                </Grid>
                <Grid Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                    <Button Background="MidnightBlue" Foreground="White" FontSize="14" FontWeight="Medium" Click="GetTenMoreEvents">
                        <Button.Content>
                            <TextBlock Text="10 till"/>
                        </Button.Content>
                    </Button>
                </Grid>
            </Grid>
        </Expander>
    </Grid>

我认为IsExpanded="True"可以做到这一点。但没有什么不同。在图片中你可以看到我的设计。在这里,我希望我的扩展器显示我的“旧事件”列表视图。所以问题出在Visual Studio中,而不是在我解雇程序的时候。 I want too see whats in the Old events expander

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我现在找到了解决问题的方法。 我对<Grid>做错了,加了太多了。

<Grid Grid.Row="2" Height="30" Background="{StaticResource HeaderBackground}" Margin="5">
        <TextBlock Foreground="{StaticResource HeaderText}" Text="Old Events" FontSize="15" Margin="10,0,0,0" />
    </Grid>
    <Grid Grid.Row="3">
        <Expander HorizontalAlignment="Left"
                  VerticalAlignment="Center"
                  ExpandDirection="Down">
            <Grid Margin="5,0,5,0" Grid.IsSharedSizeScope="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions >
                    <ColumnDefinition Width="80" SharedSizeGroup="A" />
                    <ColumnDefinition Width="150" SharedSizeGroup="B" />
                    <ColumnDefinition SharedSizeGroup="B" />
                    <ColumnDefinition Width="106" SharedSizeGroup="C" />
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="FontSize" Value="15"/>
                        <Setter Property="FontWeight" Value="Bold"/>
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Margin" Value="0,0,0,2"/>
                    </Style>
                </Grid.Resources>
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Id" />
                    <TextBlock Grid.Row="0" Grid.Column="1" Text="Event"/>
                    <TextBlock Grid.Row="0" Grid.Column="2" Text="Name"/>
                    <TextBlock Grid.Row="0" Grid.Column="3" Text="Timestamp"/>
                    <Border Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="4" BorderThickness="0,0,0,1" BorderBrush="Black"/>

                <ListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OldEventsListView" Style="{x:Null}" ItemsSource="{Binding NotificationEvents}" BorderThickness="0" Width="488" Height="150" HorizontalAlignment="Left" Grid.RowSpan="2">
                    <ListView.Resources>
                        <DataTemplate DataType="{x:Type model:NotificationEvent}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition SharedSizeGroup="A" />
                                    <ColumnDefinition SharedSizeGroup="B" />
                                    <ColumnDefinition SharedSizeGroup="B"/>
                                    <ColumnDefinition SharedSizeGroup="C"/>
                                </Grid.ColumnDefinitions>

                                <Grid.Resources>
                                    <Style TargetType="TextBlock">
                                        <Setter Property="Height" Value="30"/>
                                        <Setter Property="HorizontalAlignment" Value="Left"/>
                                        <Setter Property="VerticalAlignment" Value="Center"/>
                                    </Style>
                                </Grid.Resources>
                                <Border BorderThickness="0,0,0,1" BorderBrush="LightGray" Grid.ColumnSpan="4" Margin="0,5,0,5" />
                                <TextBlock Grid.Column="0" Text="{Binding Id}" />
                                <TextBlock Grid.Column="1" Text="{Binding Event}"/>
                                <TextBlock Grid.Column="2" Text="{Binding Name}"/>
                                <TextBlock Grid.Column="3" Text="{Binding TimeStamp}"/>
                            </Grid>
                        </DataTemplate>
                    </ListView.Resources>
                </ListView>
                <Button Grid.Row="2" Grid.Column="3" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="MidnightBlue" Foreground="White" FontSize="14" FontWeight="Medium" Click="GetTenMoreEvents">
                    <Button.Content>
                        <TextBlock Text="10 till"/>
                    </Button.Content>
                </Button>
            </Grid>
        </Expander>
    </Grid>

所以我删除<Grid Grid.Row="0" Margin="5,0,5,0" Grid.IsSharedSizeScope="True">,因为这是完全错误的。现在扩展器就像一个魅力。