Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top