문제

I know i have made some silly mistake. But won't able to solve.

This is the xaml code:

 <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>

And the screen shot is :enter image description here

도움이 되었습니까?

해결책

You're using the DataTemplate property which affects databound data. From the screenshot it looks like you're in VS designer rather than actually running the application. In that case you can set the 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>

If you're just testing the layout then your DataTemplate should be fine and can be tested by setting a source for the ListBox (such as via myListBox.ItemsSource or data binding if have that set up).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top