我试图做的是使用silverlight在xna中创建一个弹出窗口,但它抛出一个错误,说'system.windows.media.color'和'Microsoft.xna.framework.color'的引用存在歧义,有没有解决方案...如果有的话,任何建议都会非常有用。
编辑:
好的,这已经奏效了,但我现在有另一个问题,出现一个错误,说“元素已经是另一个元素的子元素”......有人可以帮我吗?到达“myStackPanel.Children.Add(txtNameEntry);”时会引发错误 线...
Border border = new Border();
border.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.White);
border.BorderThickness = new Thickness(10);
StackPanel myStackPanel = new StackPanel();
myStackPanel.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);
//Textblock containing the name you input and its properties.
//txtNameEntry.Text = Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName").ToString();
txtNameEntry.Text = "Player 1";
txtNameEntry.Width = 350;
txtNameEntry.Height = 100;
txtNameEntry.MaxLength = 10;
txtNameEntry.FontFamily = new System.Windows.Media.FontFamily("Comis Sans MS");
txtNameEntry.FontSize = 48.0;
//txtNameEntry.Foreground = new System.Windows.Media.FontFamily(Colors.Orange);
txtNameEntry.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Orange);
txtNameEntry.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray);
txtNameEntry.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray);
//The ok button, which then allows you to procede into the game.
Button btnNameEntryOK = new Button();
btnNameEntryOK.Content = "Ok";
btnNameEntryOK.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Orange);
btnNameEntryOK.FontFamily = new System.Windows.Media.FontFamily("Comic Sans Ms");
btnNameEntryOK.FontSize = 25.0;
btnNameEntryOK.Width = 180;
btnNameEntryOK.Height = 70;
btnNameEntryOK.Click += new RoutedEventHandler(btnNameEntryOK_Click);
btnNameEntryOK.Margin = new Thickness(10);
//Place these in the order you want them to be renderd to the screen.
myStackPanel.Children.Add(txtNameEntry);
myStackPanel.Children.Add(btnNameEntryOK);
border.Child = myStackPanel;
nameEntry.Child = border;
//set screen position of pop up
nameEntry.VerticalOffset = 100.0;
nameEntry.HorizontalOffset = 50.0;
//open pop up
nameEntry.IsOpen = true;
XAML:
<phone:PhoneApplicationPage
x:Class="MazeEscapePhoneSilveright.GamePage"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
shell:SystemTray.IsVisible="False">
<!--No XAML content is required as the page is rendered entirely with the XNA Framework-->
</phone:PhoneApplicationPage>