2011-04-14 3 views
0

Windows Phone 앱을 개발 중입니다.Pop Up : 여백 문제 Top

나는 팝업을 표시하는 사용자 정의 컨트롤을 사용

<UserControl x:Class="XXXXXXX.Views.Lists.GameDescriptionControl" 
    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}" Height="290" Width="460"> 

    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}" Margin="0,0,0,0" Width="460"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="133"/> 
      <RowDefinition Height="86"/> 
     </Grid.RowDefinitions> 
     <TextBlock HorizontalAlignment="Center" Margin="10" Name="gameDescription" Text="" VerticalAlignment="Top" TextWrapping="Wrap" Grid.Row="1" Style="{StaticResource PhoneTextTitle3Style}" /> 
     <Button Content="{Binding Path=AppResources.Yes, Source={StaticResource LocalizedStrings}}" Height="72" HorizontalAlignment="Left" Margin="50,5,0,0" Name="okButton" VerticalAlignment="Top" Width="160" Click="okButton_Click" Grid.Row="2" /> 
     <Button Content="{Binding Path=AppResources.No, Source={StaticResource LocalizedStrings}}" Height="72" HorizontalAlignment="Left" Margin="244,5,0,0" Name="cancelButton" VerticalAlignment="Top" Width="160" Click="cancelButton_Click" Grid.Row="2" /> 
     <TextBlock Grid.Row="0" x:Name="caption" HorizontalAlignment="Left" Margin="10" TextWrapping="Wrap" Text="{Binding Path=AppResources.Description, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextLargeStyle}"/> 
    </Grid> 
</UserControl> 

을 그리고 이것은 팝업 표시하는 코드입니다 :

private void showInfo(int gameId) 
{ 
    string gameDesc = getGameInfo(gameId); 
    p = new Popup(); 
    GameDescriptionControl gd = new GameDescriptionControl(); 
    gd.Description = gameDesc; 
    gd.OkClicked += new EventHandler(gd_OkClicked); 
    gd.CancelClicked += new EventHandler(gd_CancelClicked); 

    p.Child = gd; 

    // Set where the popup will show up on the screen. 
    p.VerticalOffset = 10; 
    p.HorizontalOffset = 10; 

    // Open the popup. 
    p.IsOpen = true; 
} 

을하지만이 얻을 :

Caption without margin top

캡션 TextBlock에는 여백 위쪽이 없습니다.

어떤 조언이 필요합니까?

답변

0

여백은 텍스트 블록 외부 영역을 나타냅니다. 텍스트 블록 가장자리에서 텍스트를 이동하려면 Padding 특성을 사용해야합니다.

+0

아니, 내가 그 자막 TextBlock이 원하는 (텍스트로 = "설명"참조) 마진 = 10있다. – VansFannel

0

단어 clip처럼 행동하지 않아도되지만 사용자 정의 MessageBox를 만드는 것처럼 보입니다.

이 구현을 확인하십시오 : http://cloudstore.blogspot.com/2011/01/customizing-messagebox-on-windows-phone.html. 아주 사용하기 쉽고, 실제 MessageBox와 매우 비슷하게 보이고/동작하며, 가벼운 MessageBox의 훌륭한 구현입니다.

당신이해야 할 것입니다, 솔루션과 함께 제공되는 몇 개의 파일을 추가 :

private MessageBoxService mbs = new MessageBoxService(); 

    ... 

mbs.Closed +=new System.EventHandler(mbs_Closed); 
mbs.Show("Confirm?","Are you sure you wish to do that?",MessageBoxServiceButton.YesNo,null); 

void mbs_Closed(object sender, System.EventArgs e) 
     { 
      mbs.Closed -= mbs_Closed; 

      if (mbs.Result == MessageBoxResult.Yes) 
      { 
... 
      } 
     } 
+0

고마워요,하지만 왜 그 한계를 잃었는지 알고 싶습니다. – VansFannel