2017-12-24 46 views
0

내가 가진 현재 A A DockPanel에서 ListBox (즉 멋진 Diaballik 게임을 나타냄) 나는 그림과 같은 상자에 의해 만들어진 격자를 통해 라벨 승리를 표시 할 수 있도록하려는 말 :WPF에서 ListBox를 통해 Label을 어떻게 추가합니까?

enter image description here

<DockPanel> 
    <ListBox DockPanel.Dock="Top" ItemsSource="{Binding Cases}" SelectedItem="{Binding SelectedCase, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Top" SnapsToDevicePixels="True"> 

     <ListBox.ItemsPanel> 
      <ItemsPanelTemplate> 
       <UniformGrid Columns="{Binding Size}"/> 
      </ItemsPanelTemplate> 
     </ListBox.ItemsPanel> 

     <ListBox.ItemContainerStyle> 
      <Style TargetType="ListBoxItem"> 
       <Setter Property="Padding" Value="0"/> 
      </Style> 
     </ListBox.ItemContainerStyle> 

     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <Grid > 
        <Ellipse Fill="{Binding Color}" Width="50" Height="50" Visibility="{Binding HasPawn, Converter={StaticResource bool2visibility}}"/>       
        ... 
       </Grid> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
    </ListBox> 

    <Label Content="VICTORY" /> <!-- How can this go over the list box ? --> 
</DockPanel> 

답변

1

당신이 뭔가를 할 수있다 (A Grid의 동작은입니다 그 것이다 단지 서로의 "위에" "스택"항목) :

<DockPanel> 
    <Grid DockPanel.Dock="Top"> 
     <ListBox ItemsSource="{Binding Cases}" SelectedItem="{Binding SelectedCase, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Top" SnapsToDevicePixels="True"> 

      <ListBox.ItemsPanel> 
       <ItemsPanelTemplate> 
        <UniformGrid Columns="{Binding Size}"/> 
       </ItemsPanelTemplate> 
      </ListBox.ItemsPanel> 

      <ListBox.ItemContainerStyle> 
       <Style TargetType="ListBoxItem"> 
        <Setter Property="Padding" Value="0"/> 
       </Style> 
      </ListBox.ItemContainerStyle> 

      <ListBox.ItemTemplate> 
       <DataTemplate> 
        <Grid > 
         <Ellipse Fill="{Binding Color}" Width="50" Height="50" Visibility="{Binding HasPawn, Converter={StaticResource bool2visibility}}"/>       
         ... 
        </Grid> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 
     </ListBox> 

     <Label Content="VICTORY" HorizontalAlignment="Center" VerticalAlignment="Center" /> <!-- How can this go over the list box ? --> 
    </Grid> 
</DockPanel>