2011-07-27 31 views
2

我正在使用Silverlight並最終使用Silverlight作爲電話。是否有可能將網格控件作爲容器控件進行操作

我所要做的是創建一個包含兒童控件邊框的容器。在網格控件的邊界之外時,子控件不應該可見。

這可能嗎?我知道我可以從路徑創建一個剪輯,但這是唯一的方法。

我沒有使用滾動容器,這似乎工作....一些。

這是xaml。我期待的是當應用運行時第二個按鈕不可見。

<Grid x:Name="LayoutRoot" Background="White" > 
    <Grid HorizontalAlignment="Left" VerticalAlignment="Top" Height="197" Width="241" d:LayoutOverrides="HorizontalAlignment, VerticalAlignment"> 
     <Button Content="Button" Margin="25,42,101,81"/> 
     <Button Content="Button" Height="76" Margin="25,0,63,-83" VerticalAlignment="Bottom"/> 
    </Grid> 
</Grid> 
+0

不知道你是問什麼 - 通常情況下,子元素也不會,除非你Grid元素外可見正在使用類似TranslateTransform的東西。 –

+0

讓我感到困惑的是,包含的網格邊界似乎除了作爲參考點之外沒有做任何事情。包含的網格似乎與根(虛擬)的大小相同 –

+0

我仍不明白你的問題,但爲了回答你最後的評論,網格總是取其容器的大小,因此包含的網格將完全相同大小作爲LayoutRoot網格。 –

回答

0

我發現周圍的工作,但喜歡使用另一種解決方案。我使用了scrollviewer並隱藏了滾動條。這似乎是一個沉重的解決方案,但暫時還是有效的。我肯定會需要找到一些較輕的重量,當我提出這個到Windows Phone 7

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" mc:Ignorable="d" 
x:Class="SilverlightApplication2.MainPage" 
Width="640" Height="480"> 
<Grid x:Name="LayoutRoot" Background="White" > 
    <ScrollViewer x:Name="scrollViewer" Margin="0,0,158,0" VerticalScrollBarVisibility="Disabled" Height="123" VerticalAlignment="Top"> 
     <Grid x:Name="grid" VerticalAlignment="Top" MaxWidth="169" MaxHeight="145" Height="141" RenderTransformOrigin="0.5,0.5"> 
      <Grid.RenderTransform> 
       <CompositeTransform/> 
      </Grid.RenderTransform> 
      <Button Content="Button" Margin="25,42,0,60" HorizontalAlignment="Left" Width="71"/> 
      <Button Content="Button" Height="76" Margin="25,0,0,-83" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="81"/> 
     </Grid> 
    </ScrollViewer> 
</Grid> 

0

因爲你似乎會問什麼是怎麼Grid控制工作在默認情況下,如:

<Page 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <DockPanel Margin="50" Background="Azure" > 
    <Grid> 
     <TextBlock>The only part of this control that gets rendered is that which is inside the bounds of the Grid.</TextBlock> 
    </Grid> 
    </DockPanel> 
</Page> 

我只能假設你在問別的東西。但是什麼?

+0

我認爲你的權利,但這似乎只適用於根佈局。 –

相關問題