如何在ListBox上放置弹出控件

时间:2013-10-11 00:50:45

标签: c# windows-phone-7 windows-phone-8 listbox popup

在满足某个条件后,我想在ListBox上放置一个Popup。当我在以下代码中执行此操作时,我在页面构造函数中的XamlParseException上获得InitializeComponent()。我不确定为什么?

EditPage.xaml

<Grid>
    <ListBox Name="ListBoxEffects" SelectionMode="Single" ItemsSource="{Binding}" Margin="{Binding}" toolkit:TiltEffect.IsTiltEnabled="True" SelectionChanged="ListBox_SelectionChanged" >
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                 <toolkit:WrapPanel ItemWidth="146" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
             <DataTemplate>
                 <StackPanel Orientation="Vertical" Margin="12,0,0,24" >
                     <Image Source="{Binding Thumbnail}" Width="134" Height="134" />
                     <TextBlock Text="{Binding Name}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeNormal}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                  </StackPanel>
              </DataTemplate>
         </ListBox.ItemTemplate>
    </ListBox>
    <Popup x:Name="trialPopup">
        <Border Margin="3" BorderBrush="{StaticResource PhoneForegroundBrush}">
            <StackPanel Background="FF1BA1E2">
                 <TextBlock Text="Do you wish to purchase the application?" TextWrapping="Wrap"/>
                 <StackPanel Orientation="Horizontal" Margin="0,10">
                     <Button x:Name="purchaseButton" Content="purchase" Click="popupButton_Click"/>
                     <Button x:Name="cancelButton" Content="cancel" Click="popupButton_Click"/>
                 </StackPanel>
             </StackPanel>
         </Border>
     </Popup>
</Grid>

出于测试目的,我只是想在导航到EditPage时立即显示弹出窗口,这样我就可以看到它的外观和主题,但是在生产中,这只会在满足某个要求后显示。我怎样才能真正测试看ListBox上的弹出显示?

1 个答案:

答案 0 :(得分:0)

正如评论中参见夏普所述,问题出在以下几行:

<StackPanel Background="FF1BA1E2">

哈希符号(或数字符号)必须用作十六进制颜色的前缀:

<StackPanel Background="#FF1BA1E2">


有关更多详细信息,请参阅此相关答案:https://stackoverflow.com/a/1484842/247257