2013-09-18 4 views
2

나는 바보 같은 실수를 저질렀습니다. 그러나 해결할 수 없을 것입니다. Listbox 데이터 형식이 작동하지 않습니다.

는 XAML 코드 :

<Border BorderBrush="Red" BorderThickness="3" Grid.Column="0" Grid.Row="0"> 
         <toolKit:ListBoxDragDropTarget AllowDrop="True" > 

         <ListBox Height="85" Width="120"> 
          <ListBox.ItemTemplate> 
           <DataTemplate> 
              <TextBlock Text="12233" Foreground="AliceBlue"/> 
            </DataTemplate> 
          </ListBox.ItemTemplate> 
         </ListBox> 

        </toolKit:ListBoxDragDropTarget> 
        </Border> 

그리고 스크린 샷입니다 : 당신은 데이터 바인딩 된 데이터에 영향을 미치는 DataTemplate 속성을 사용하고 enter image description here

+0

ListBox에 ListBoxItem을 추가해야합니다. ListBox의 ItemTemplate을 정의했지만 ListBox에는 항목이 없습니다. – Jehof

답변

0

. 스크린 샷에서 실제로 애플리케이션을 실행하는 대신 VS 디자이너에있는 것처럼 보입니다. 이 경우 ItemContainerStyle을 설정할 수 있습니다.

<ListBox> 
    <ListBox.ItemContainerStyle> 
     <Style TargetType="ListBoxItem"> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ListBoxItem"> 
        <TextBlock Text="12233" Foreground="AliceBlue" />       
        </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
     </Style> 
    </ListBox.ItemContainerStyle> 
    <ListBoxItem>My ListBoxItem</ListBoxItem> 
</ListBox> 

그냥 다음 DataTemplate 괜찮을 레이아웃을 테스트하고 (예 : 설정하는 것이있는 경우 바인딩 myListBox.ItemsSource 또는 데이터를 통해 같은) ListBox에 대한 소스를 설정하여 테스트 할 수 있습니다.

+0

감사합니다. 그것은 완벽하게 작동합니다. –