wpf listbox绑定图片拖放到canvas中?? 我用listbox绑定了photos(自定的类),想把listbox中的图片拖动到旁边的画布中。请高人指教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是我的xaml 代码<Window x:Class="WpfDragDrop.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Drop and Drag" Height="800" Width="800"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <DockPanel Name="_dockPanel" DataContext="{DynamicResource photos}" Background="Blue" Width="160" Uid="5" AllowDrop="True" HorizontalAlignment="Left" Margin="0,0,0,22"> <ListBox x:Name="pictureBox" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.IsDeferredScrollingEnabled="True" > <ListBox.Resources> <Style TargetType="{x:Type ListBoxItem}"> <!--<Setter Property="Width" Value="100"/>--> <EventSetter Event="MouseLeftButtonDown" Handler="DragImage"/> </Style> </ListBox.Resources> <ListBox.ItemTemplate> <DataTemplate> <Image Source="{Binding Path=FullPath}" Margin="5,8" Height="50"> <Image.LayoutTransform> <StaticResource ResourceKey="st" /> </Image.LayoutTransform> <Image.ToolTip> <StackPanel> <TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=DateTime}" /> </StackPanel> </Image.ToolTip> </Image> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </DockPanel> <Canvas x:Name="Canvas1" Grid.Column="1" AllowDrop="True" Margin="5" Drop="DropImage"> </Canvas> </Grid></Window> 那位大侠出手相助,我可以把源代码呈上。留下你的Email。 解决没? [email protected] 关于Socket模拟浏览器操作的问题 跪求1!+2!+3!+....+10!算法 API函数PostMessage在WindowsXP下能正常运行,但在Windows98下面的不能正常运行? .net有那些日期工具类 WPF 3D 透明问题 谁能告诉我能够绑定的数据类型都有那些? C# 共享桌面,可1对多的 如何得知一台机器上两块网卡的局域网网卡的IP? Help me!大虾们,C#写浏览器的资料,或类库! 一个remoting的基本问题 Reflector反编译EXE程序,提示“未引用到对象实例” ,这样的情况怎么反编译? 字符串中加空格求比较简洁的方法
<Window x:Class="WpfDragDrop.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Drop and Drag" Height="800" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions>
<DockPanel Name="_dockPanel" DataContext="{DynamicResource photos}" Background="Blue" Width="160" Uid="5" AllowDrop="True" HorizontalAlignment="Left" Margin="0,0,0,22">
<ListBox x:Name="pictureBox" ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.IsDeferredScrollingEnabled="True" >
<ListBox.Resources> <Style TargetType="{x:Type ListBoxItem}"> <!--<Setter Property="Width" Value="100"/>--> <EventSetter Event="MouseLeftButtonDown" Handler="DragImage"/> </Style> </ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding Path=FullPath}" Margin="5,8" Height="50">
<Image.LayoutTransform>
<StaticResource ResourceKey="st" />
</Image.LayoutTransform>
<Image.ToolTip>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=DateTime}" />
</StackPanel>
</Image.ToolTip>
</Image>
</DataTemplate>
</ListBox.ItemTemplate> <ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</DockPanel> <Canvas x:Name="Canvas1" Grid.Column="1" AllowDrop="True" Margin="5" Drop="DropImage"> </Canvas> </Grid>
</Window>