2016-05-13 73 views
0

我怎樣才能看到我的設計這擴展器在設計視圖?我使用VS2015。我想看看我的設計是在擴展器XAML

<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

感謝您的幫助。

+0

我試過你的代碼,即使沒有'IsExpanded'屬性,'expander'也會在'設計模式'下展開。我認爲原因不在你發佈的代碼中。 –

+3

和這個''有兩個引號 –

+0

哦okey @Paolo Go。我會嘗試找到一些東西並在這裏發佈。 ''''在這裏只是一個錯字,而不是我的真實代碼,但感謝noties。 –

回答

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">,因爲這是完全錯誤的。現在膨脹機作爲一種魅力。