2014-01-13 53 views
0

我剛開始使用WP7。我想知道是否有更合適的方法來做到這一點,但現在這似乎是最合乎邏輯的方法。我想,以顯示國家的名單及其相關電話代碼,就像這樣:列表框不顯示縱向或橫向模式下的所有項目

<Grid x:Name="ContentPanel" Grid.Row="0" Margin="12,0,12,0"> 
    <ScrollViewer Name="ScrollViewer" Height="3500"> 
     <StackPanel Name="StackPanel" Height="3500"> 
      <ListBox Name="codeList" FontSize="26" SelectionChanged="codeList_SelectionChanged"> 
       <ListBoxItem Name="US">United States (+1)</ListBoxItem> 
       <ListBoxItem Name="AG">Afghanistan (+93)</ListBoxItem> 
       <ListBoxItem Name="AR">Argentina (+54)</ListBoxItem> 
       <ListBoxItem Name="AU">Australia (+62)</ListBoxItem> 
       <ListBoxItem Name="AS">Austria (+43)</ListBoxItem> 
       <ListBoxItem Name="BE">Belgium (+32)</ListBoxItem> 
       <ListBoxItem Name="BU">Bulgaria (+359)</ListBoxItem> 
       <ListBoxItem Name="BR">Brazil (+55)</ListBoxItem> 
       <ListBoxItem Name="CL">Chile (+56)</ListBoxItem> 
       <ListBoxItem Name="CN">China (+86)</ListBoxItem> 
       <ListBoxItem Name="CO">Colombia (+57)</ListBoxItem> 
       <ListBoxItem Name="DK">Denmark (+45)</ListBoxItem> 
       <ListBoxItem Name="EG">Egypt (+20)</ListBoxItem> 
       <ListBoxItem Name="FR">France (+33 )</ListBoxItem> 
       <ListBoxItem Name="DE">Germany (+49)</ListBoxItem> 
       <ListBoxItem Name="GR">Greece (+30)</ListBoxItem> 
       <ListBoxItem Name="HN">Hungary (+36)</ListBoxItem> 
       <ListBoxItem Name="IN">India (+91)</ListBoxItem> 
       <ListBoxItem Name="IT">Italy (+39)</ListBoxItem> 
       <ListBoxItem Name="JP">Japan (+81)</ListBoxItem> 
       <ListBoxItem Name="MX">Mexico (+52)</ListBoxItem> 
       <ListBoxItem Name="ND">Netherlands (+31)</ListBoxItem> 
       <ListBoxItem Name="NO">Norway (+47)</ListBoxItem> 
       <ListBoxItem Name="PE">Peru (+51)</ListBoxItem> 
       <ListBoxItem Name="PO">Poland (+48)</ListBoxItem> 
       <ListBoxItem Name="PT">Portugal (+351)</ListBoxItem> 
       <ListBoxItem Name="ES">Spain (+34)</ListBoxItem> 
       <ListBoxItem Name="SE">Sweden (+46)</ListBoxItem> 
       <ListBoxItem Name="SW">Switzerland (+41)</ListBoxItem> 
       <ListBoxItem Name="TK">Turkey (+90)</ListBoxItem> 
       <ListBoxItem Name="UR">Uruguay (+598)</ListBoxItem> 
       <ListBoxItem Name="VE">Venezuela (+58)</ListBoxItem> 
       <ListBoxItem Name="ZI">Zimbabwe (+263)</ListBoxItem> 
      </ListBox> 
     </StackPanel> 
    </ScrollViewer> 
</Grid> 

事實證明,在人像模式,列表只顯示了波蘭,並在景觀,直到希臘。無論我增加Scrollviewer和StackPanel大小,都無關緊要。有什麼建議麼?

回答

1

在這個佈局中StackPanel和ScrollViewer是不必要的,因爲ListBox自己滾動。問題在於你沒有限制Grid行的高度,這會導致Grid Row中的項佔用儘可能多的高度。只需添加以下內容:

<Grid.RowDefinitions> 
<RowDefinition Height="*" /> 
</Grid.RowDefinitions> 

...網格標籤的下面,然後刪除的ScrollViewer和StackPanel的標籤,你應該是好去。

讓我知道如果它不起作用,我會自己嘗試。這只是我的頭頂。

HTH!

+0

曾任職像一個魅力。直到今晚才能測試它。謝謝! –

+0

很高興工作!不要忘記upvote – AdvancedREI

0

我同意AdvancedREI。

如果使用默認的項目模板,那麼你已經定格,成爲父母的頂行,其大小設置爲AUTO:

<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

而且整個頁面的其給列表框的大小,限制它。所以,如果你想設置列表框中的全頁面上,使用此:

<Grid x:Name="LayoutRoot" Background="Transparent"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
       <ListBox Name="codeList" FontSize="26"> 
        <ListBoxItem Name="US">United States (+1)</ListBoxItem> 
        <ListBoxItem Name="AG">Afghanistan (+93)</ListBoxItem> 
        <ListBoxItem Name="AR">Argentina (+54)</ListBoxItem> 
        <ListBoxItem Name="AU">Australia (+62)</ListBoxItem> 
        <ListBoxItem Name="AS">Austria (+43)</ListBoxItem> 
        <ListBoxItem Name="BE">Belgium (+32)</ListBoxItem> 
        <ListBoxItem Name="BU">Bulgaria (+359)</ListBoxItem> 
        <ListBoxItem Name="BR">Brazil (+55)</ListBoxItem> 
        <ListBoxItem Name="CL">Chile (+56)</ListBoxItem> 
        <ListBoxItem Name="CN">China (+86)</ListBoxItem> 
        <ListBoxItem Name="CO">Colombia (+57)</ListBoxItem> 
        <ListBoxItem Name="DK">Denmark (+45)</ListBoxItem> 
        <ListBoxItem Name="EG">Egypt (+20)</ListBoxItem> 
        <ListBoxItem Name="FR">France (+33 )</ListBoxItem> 
        <ListBoxItem Name="DE">Germany (+49)</ListBoxItem> 
        <ListBoxItem Name="GR">Greece (+30)</ListBoxItem> 
        <ListBoxItem Name="HN">Hungary (+36)</ListBoxItem> 
        <ListBoxItem Name="IN">India (+91)</ListBoxItem> 
        <ListBoxItem Name="IT">Italy (+39)</ListBoxItem> 
        <ListBoxItem Name="JP">Japan (+81)</ListBoxItem> 
        <ListBoxItem Name="MX">Mexico (+52)</ListBoxItem> 
        <ListBoxItem Name="ND">Netherlands (+31)</ListBoxItem> 
        <ListBoxItem Name="NO">Norway (+47)</ListBoxItem> 
        <ListBoxItem Name="PE">Peru (+51)</ListBoxItem> 
        <ListBoxItem Name="PO">Poland (+48)</ListBoxItem> 
        <ListBoxItem Name="PT">Portugal (+351)</ListBoxItem> 
        <ListBoxItem Name="ES">Spain (+34)</ListBoxItem> 
        <ListBoxItem Name="SE">Sweden (+46)</ListBoxItem> 
        <ListBoxItem Name="SW">Switzerland (+41)</ListBoxItem> 
        <ListBoxItem Name="TK">Turkey (+90)</ListBoxItem> 
        <ListBoxItem Name="UR">Uruguay (+598)</ListBoxItem> 
        <ListBoxItem Name="VE">Venezuela (+58)</ListBoxItem> 
        <ListBoxItem Name="ZI">Zimbabwe (+263)</ListBoxItem> 
       </ListBox> 
    </Grid> 
</Grid> 

,我看你在國家代碼忘了拉脫維亞,我們也一樣偉大的新的應用程序=)

+0

我會加拉脫維亞,但這並不意味着它是一個完整的應用程序(還):P –

相關問題