如何放大DevExpress DXGrid for WPF单元格中的图像?
作者:zhuhm 来源:本站原创 浏览:Loading...次 发布时间:2012-09-04 评论:0条
在窗口中创建一个标准图像控件,并且当用户点击图像时,你还可以隐藏或者显示该控件。网格单元格中的图像应该被绑定在按钮中。这样,你就可以轻松处理Click事件了。
<Window Height="598" 
  Title="Window1" 
  Width="811" 
  x:Class="WpfApplication1.Window1" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
  xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
  xmlns:local="clr-namespace:WpfApplication1" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  
  <Grid>
  <dxg:GridControl Name="gridControl1">
  <dxg:GridControl.Columns>
  <dxg:GridColumn FieldName="CategoryID" />
  <dxg:GridColumn FieldName="CategoryName" />
  <dxg:GridColumn FieldName="Picture" AllowColumnFiltering="False">
  <dxg:GridColumn.CellTemplate>
  <DataTemplate>
  <Button Command="{x:Static local:Window1.ShowImage}">
  <Button.Template>
  <ControlTemplate TargetType="{x:Type Button}">
  <ContentPresenter />
  </ControlTemplate>
  </Button.Template>
  
  <Image Source="{Binding Path=RowData.Row[Picture]}" HorizontalAlignment="Left" Stretch="None" />
  </Button>
  </DataTemplate>
  </dxg:GridColumn.CellTemplate>
  </dxg:GridColumn>
  </dxg:GridControl.Columns>
  
  <dxg:GridControl.View>
  <dxg:TableView x:Name="view" AutoWidth="True" />
  </dxg:GridControl.View>
  </dxg:GridControl>
 <Image Source="{Binding}" Name="image" Visibility="Hidden" MouseLeave="image_MouseLeave" Margin="30,30,50,12" />
  </Grid>
</Window>
<Window Height="598" 
  Title="Window1" 
  Width="811" 
  x:Class="WpfApplication1.Window1" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
  xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
  xmlns:local="clr-namespace:WpfApplication1" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 <Grid>
  <dxg:GridControl Name="gridControl1">
  <dxg:GridControl.Columns>
  <dxg:GridColumn FieldName="CategoryID" />
  <dxg:GridColumn FieldName="CategoryName" />
  <dxg:GridColumn FieldName="Picture" AllowColumnFiltering="False">
  <dxg:GridColumn.CellTemplate>
  <DataTemplate>
  <Button Command="{x:Static local:Window1.ShowImage}">
  <Button.Template>
  <ControlTemplate TargetType="{x:Type Button}">
  <ContentPresenter />
  </ControlTemplate>
  </Button.Template>
  
  <Image Source="{Binding Path=RowData.Row[Picture]}" HorizontalAlignment="Left" Stretch="None" />
  </Button>
  </DataTemplate>
  </dxg:GridColumn.CellTemplate>
  </dxg:GridColumn>
  </dxg:GridControl.Columns>
  
  <dxg:GridControl.View>
  <dxg:TableView x:Name="view" AutoWidth="True" />
  </dxg:GridControl.View>
  </dxg:GridControl>
 <Image Source="{Binding}" Name="image" Visibility="Hidden" MouseLeave="image_MouseLeave" Margin="30,30,50,12" />
  </Grid>
</Window>
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [http://www.devexpresscn.com/]
本文地址:http://www.devexpresscn.com/DevExpress-Resources/Documentation-221.html
关键字: DevExpress DXGrid
评论列表
暂无评论
请谈谈你的看法 请使用IE或者Firefox浏览器,暂不支持Chrome!

慧都控件网为DevExpress界面控件的中国地区唯一正式授权经销商,正版控件销售公司,授权代理商,经销商及合作伙伴。
电话:400-700-1020
              023-66090381
邮箱:sales@evget.com
相关资源
- 如何绑定实体框架对象到XtraGrid
 - 使用CreatePrintInfoInstance导出自定义文本和Gridbands
 - GridView中格式化数据显示的问题
 - 显示AgDataGrid主从数据
 - GridControl运行时是否可以不选中任何行
 - XtraGrid网格行热跟踪
 - DXGrid的列能不能通过双击列表头实现
 - 如何获取GridView的页面列值
 - DXPivotGrid如何增加一列百分比
 - DXGrid单元格样式
 - DevExpress历史版本下载地址大全
 - 更改数据单元格的呈现效果
 - ASPxGridView分组排序
 - DXChart与透视网格控件集成例子中图例显示的问题
 - WPF表格控件GridControl如何设置行高
 - 定义DXGrid的打印外观
 - ASPxGridView控件FAQ
 - ASPxGridView主要特征以及方法
 - ASPxGridView不支持编辑数据
 - 如何序列化包含可序列化的DX控件的WPF窗体
 
 
    


