wpf怎样实现datagrid控件文本可选

bforesc 2014-07-29 06:20:30
wpf怎样实现datagrid控件文本可选?? 就像网页文字那样,可以刮选文本内容。。。。
...全文
189 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
asia217 2014-08-12
  • 打赏
  • 举报
回复
     <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Border x:Name="border" Visibility="{Binding Item.C3.visibility}"  Style="{StaticResource boderStyle}" >
                                                <Grid x:Name="gdContent" Margin="3" >
                                                    <TextBlock Foreground="Black" Text="{Binding Item.C3.productname}" Background="{Binding Item.C3.backgroud}"  ToolTip="{Binding Item.C3.productname}">
														<i:Interaction.Triggers>
															<i:EventTrigger EventName="MouseDown">
																<i:InvokeCommandAction CommandParameter="{Binding Item.C3.spaceCellInfo}" Command="{Binding DataContext.DetailCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
															</i:EventTrigger>
														</i:Interaction.Triggers>
                                                    </TextBlock>
                                                </Grid>
                                            </Border>
                                     
                                        </StackPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>


思路大概是:设置datagrid数据模板,点击模板里的控件时改变控件外围的border背景样式,取消点击时样式恢复
exception92 2014-07-30
  • 打赏
  • 举报
回复
据我所知,不能实现,除非你的获得你选中的行,在获取包含的子元素,获得子元素的Content or Text,拼接才文本格式,存到string里。
vbfool 2014-07-30
  • 打赏
  • 举报
回复
渲染引擎都不一样啊,没那么简单的。
  • 打赏
  • 举报
回复
直接不能选中复制吗

8,737

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧