2012-04-11 20 views
1

EDIT:ネイティブコンボボックス表示しない選択肢を正しく

<ComboBox x:Name="Result" Grid.Column="6" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" Background="White"> 
    <ComboBoxItem Content="Win" /> 
    <ComboBoxItem Content="Place" /> 
    <ComboBoxItem Content="Lose" /> 
</ComboBox> 
ListPicker を移動するための方法であるが、私は、私は、コードに次のコンボボックスを持つ詳細な Microsoft.Phone.Controls.Toolkit ListPicker throws XamlParseException

でさらに問題を抱えているようです

しかし、私は期待したとおりに表示されません。 ComboBoxをドロップダウンすると、オプションは表示されず、空のアイテムと似ています。以下を参照してください:項目が選択されている場合

enter image description here

しかし、それは正しく表示され、正しいインデックス/項目が返されます。以下を参照してください:

enter image description here

私は、私が見逃しているシンプルなものがあると確信しているが、それに私の指を置くことはできません。

編集:OK私はこれの完全なコードを投稿しています。私は、ユーザーコントロールを持って、このようになりますOddsRow、:OddsRowの作品でも

<phone:PhoneApplicationPage xmlns:my="clr-namespace:MojoPinBetOddsCalculator" 
    x:Class="MojoPinBetOddsCalculator.MainPage" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    SupportedOrientations="Portrait" Orientation="Portrait" 
    shell:SystemTray.IsVisible="True"> 

    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="Transparent"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <!--TitlePanel contains the name of the application and page title--> 
     <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
      <TextBlock x:Name="ApplicationTitle" Text="BET ODDS CALCULATOR" Style="{StaticResource PhoneTextNormalStyle}"/> 
      <TextBlock x:Name="PageTitle" Text="calculate" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
     </StackPanel> 
     <!--ContentPanel - place additional content here--> 
     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" HorizontalAlignment="Stretch"> 
      <Grid x:Name="Scrollable"> 
       <ScrollViewer> 
       <Grid x:Name="BettingGrid"> 
        <Grid.RowDefinitions> 
         <RowDefinition Height="Auto"></RowDefinition> 
         <RowDefinition Height="*"></RowDefinition> 
        </Grid.RowDefinitions> 
        <Grid x:Name="BetList"> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="30"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
          <RowDefinition Height="70"></RowDefinition> 
         </Grid.RowDefinitions> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="50*"></ColumnDefinition> 
          <ColumnDefinition Width="70*"></ColumnDefinition> 
          <ColumnDefinition Width="30*"></ColumnDefinition> 
          <ColumnDefinition Width="70*"></ColumnDefinition> 
          <ColumnDefinition Width="70*"></ColumnDefinition> 
          <ColumnDefinition Width="70*"></ColumnDefinition> 
          <ColumnDefinition Width="100*"></ColumnDefinition> 
         </Grid.ColumnDefinitions> 
         <TextBlock Text="EW" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" /> 
         <TextBlock Text="Place" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="0" Grid.Column="5" HorizontalAlignment="Center" /> 
         <TextBlock Text="Result" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="0" Grid.Column="6" HorizontalAlignment="Center" /> 
         <my:OddsRow Grid.Row="1" Grid.ColumnSpan="7" Row="1"/> 
         <my:OddsRow Grid.Row="2" Grid.ColumnSpan="7" Row="2"/> 
         <my:OddsRow Grid.Row="3" Grid.ColumnSpan="7" Row="3"/> 
         <my:OddsRow Grid.Row="4" Grid.ColumnSpan="7" Row="4"/> 
         <my:OddsRow Grid.Row="5" Grid.ColumnSpan="7" Row="5"/> 
         <my:OddsRow Grid.Row="6" Grid.ColumnSpan="7" Row="6"/> 
        </Grid> 
        <Grid x:Name="ControlsGrid" Grid.Row="1"> 
         <Button x:Name="AddRowButton" Background="#BFFFFFFF" BorderBrush="#BFFFFFFF" Foreground="Black" Content="Add Row" FontSize="16" Click="AddRowButton_Click" Height="70" /> 
        </Grid> 
       </Grid> 
       </ScrollViewer> 
      </Grid> 
     </Grid> 
    </Grid> 
</phone:PhoneApplicationPage> 

別にコンボボックスの作品を、そしてコードを:

<UserControl xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" x:Class="MojoPinBetOddsCalculator.OddsRow" 
    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" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
    d:DesignHeight="480" d:DesignWidth="480"> 

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="70"/> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="50*"></ColumnDefinition> 
      <ColumnDefinition Width="70*"></ColumnDefinition> 
      <ColumnDefinition Width="30*"></ColumnDefinition> 
      <ColumnDefinition Width="70*"></ColumnDefinition> 
      <ColumnDefinition Width="70*"></ColumnDefinition> 
      <ColumnDefinition Width="70*" ></ColumnDefinition> 
      <ColumnDefinition Width="100*"></ColumnDefinition> 
     </Grid.ColumnDefinitions> 
     <TextBlock x:Name="RowNumber" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> 
     <TextBox x:Name="OddsNumerator" Grid.Column="1" Width="90" Height="70" HorizontalAlignment="Center" TextAlignment="Center" VerticalAlignment="Center" MaxLength="3" InputScope="TelephoneNumber"></TextBox> 
     <TextBlock x:Name="Slash" Grid.Column="2" Text="/" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock> 
     <TextBox x:Name="OddsDenominator" Grid.Column="3" Width="90" Height="70" VerticalAlignment="Center" TextAlignment="Center" MaxLength="3" HorizontalAlignment="Center" InputScope="TelephoneNumber"></TextBox> 
     <CheckBox x:Name="EachWay" Grid.Column="4" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,0,0" /> 
     <CheckBox x:Name="Place" Grid.Column="5" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0" Width="71" Margin="10,0,0,0" Padding="0" /> 
     <ComboBox x:Name="Result" Grid.Column="6" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Black" Background="White"> 
      <ComboBoxItem Content="Win" /> 
      <ComboBoxItem Content="Place" /> 
      <ComboBoxItem Content="Lose" /> 
     </ComboBox> 
    </Grid> 
</UserControl> 

そしてそれはそうのようなメインページに表示されています期待どおりに...別々に。組み合わせると、アイテムは表示されません。

OddsRow.xaml.csすべての愛のために

public partial class OddsRow : UserControl 
{ 
    private int m_Row; 

    public OddsRow() 
    { 
     InitializeComponent(); 
    } 

    public int Row 
    { 
     get 
     { 
      return m_Row; 
     } 
     set 
     { 
      m_Row = value; 
      RowNumber.Text = m_Row + " - "; 
     } 
    } 
} 
+2

これは私にとってはうまくいきます。それはコンボボックスのテキストを白くするカスタムスタイルですか? – Robaticus

+0

ええええええええええええ、それは私が別々のプロジェクトに入れるときに期待どおりに動作します。たぶん誰かが何かを見つけられるかどうかを確認するために、マークアップを投稿します。 – anothershrubery

+0

OKフルマークアップが更新されました。 – anothershrubery

答えて

2

は、株式のコンボボックスを使用しないでください。 ListPickerのようなものを使用してください。これにより、アプリケーションをMetro UIと一貫して見えるようになります。

+0

私はチャンスを得たときListPickerを調べます。それを素早く見て、 'InvalidProgramException'を取得しましたが、それをより良く見て簡単にソートされていると確信しています。 – anothershrubery

+1

"+10"ボタンをクリックした場合は、@Dennisの回答をクリックします。**しないでください** ** ComboBoxコントロールを使用してListPickerに行きましょう! –

+0

私はこれを答えとしてマークしましたが、私は「ListPicker」に関するさらなる問題を抱えています。詳細については、http://stackoverflow.com/questions/10155688/microsoft-phone-controls- toolkit-listpicker-throws-xamlparseexception – anothershrubery

関連する問題