我正在尝试做的是使用silverlight在xna中创建一个弹出窗口,但它抛出了一个错误,说'system.windows.media.color‘和'Microsoft.xna.framework.color’的引用有歧义,有没有this...if的解决方案,所以任何建议都会非常有用。
编辑:
好的,这已经起作用了,但是我现在有另一个问题,一个错误出现了,说‘元素已经是另一个元素的子元素’……有人能帮我吗?当到达‘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>发布于 2013-06-26 21:10:00
如果由于通过using指令导入名称空间而产生歧义,那么可以在适当的时候为适当的Color对象使用完整的名称空间。
我不确定您需要在代码中为成员确切使用哪一个,因为您还没有发布它,但不要只使用Color,而是使用:
Microsoft.Xna.Framework.Color.YOUR_MEMBER_CALL或
System.Windows.Media.Color.YOUR_MEMBER_CALL或者,您可以从文件的顶部删除using Microsoft.Xna.Framework;或using System.Windows.Media;指令;选择最合适的。但是,您在已删除的名称空间中使用的任何其他类型都必须进行更新,以包括完整(或部分)名称空间以限定其名称。
最后一个选项是您可以指定一个namespace alias。因此,例如,如果您想要对Silverlight颜色进行特殊调用,则可以在文件的顶部添加:
using SilverlightMedia = System.Windows.Media;然后,在后面的代码中,您可以拥有:
var myColor = SilverlightMedia.Color.FromArgb(255, 255, 255, 255);https://stackoverflow.com/questions/17320928
复制相似问题