2012-04-11 3 views
1

편집 :기본 콤보 상자에 표시되지 않을 선택을 올바르게

<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

내가 놓친하지만 내 손가락을 넣지 수있는 간단한 일이있다.

편집 : 확인이 전체 코드를 게시 할 예정입니다. 나는 사용자가 제어 할 수 있습니다, 다음과 같습니다 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> 

그리고이 때문에 같은 MainPage에 표시됩니다 예상대로 ... 별도. 결합하면 항목이 표시되지 않습니다.

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

나는 올바른 답을 찾은 것 같아 답변으로 표시했으나 http://listackflow.com/questions/10155688/microsoft-phone-controls-knowledge에 자세히 나와있는'ListPicker'에 대한 추가 문제가 있습니다. 툴킷 -listpicker-throws-xamlparseexception – anothershrubery

관련 문제