2012-04-21 4 views
0

WindowsPhone에서 앱 개발을 시작하고 몇 가지 문제가 있습니다. 동적으로 캔버스를 추가하려고했지만 작동하지 않아 뭔가를 잊어 버렸을 수 있습니다. 오류를 발견하는 데 도움이 될 수 있습니까? 아래 코드는 내 학습 앱에서 가져온 것입니다. 기본 Win Phone 앱입니다.동적으로 캔버스 만들기

CS 코드 :

public MainPage() 
    { 
     InitializeComponent(); 

     int size = 50; 
     Canvas myCanvas = new Canvas(); 
     Canvas.SetLeft(myCanvas, 0); 
     myCanvas.Width = size; 

     Color c = new Color(); 
     c.R = 255; 
     c.B = 0; 
     c.G = 255; 

     myCanvas.Background = new SolidColorBrush(c); 

     ContentPanel.Height = 100; 
     ContentPanel.Width = 100; 
     ContentPanel.Children.Add(myCanvas); 
     ApplicationTitle.Text = ContentPanel.ActualHeight.ToString(); 

    } 

XAML 난 당신이 캔버스 여기 달성하기 위해 노력하고 무엇을 아주 확실하지 않다

<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="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/> 
     <TextBlock x:Name="PageTitle" Text="page name" 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"> 

    </Grid> 
</Grid> 

답변

1

. 자신이하려는 것을 얻기 위해 다른 컨트롤을 조사하고 싶을 수 있습니다.

즉, 문제는 색상에서 "알파"구성 요소가 누락되었다는 것입니다. 이것은 그것을 투명하게 만들고 있습니다.

변경 :; 는 현재, 내가 곧 일부 PNG를 넣어하는 드래그 요소를 필요로하는 게임을 만들려고 해요)

Color c = new Color(); 
    c.R = 255; 
    c.B = 0; 
    c.G = 255; 

    c.A = 255; // this is what you need to add to make it visible. 
+0

덕분에, 당신은 내 일했다. –

+0

도와 드리겠습니다. 게임에 행운을 비네! – Robaticus