WPF dev GridControl 鼠标移上去显示Tooltip

来源:互联网 发布:炫酷个人网站php源码 编辑:程序博客网 时间:2024/05/18 01:23
ToolTip代码应用:
 
<dxg:GridColumn FieldName="EndOnFrameCode" Header="对端配线架编码"  HorizontalHeaderContentAlignment="Center" Width="150" AllowEditing="False"   >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                            <dxg:GridColumn.CellStyle>                                <Style BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=LightweightCellStyle}}" TargetType="{x:Type dxg:LightweightCellEditor}">                                    <Setter Property="ToolTip" Value="{Binding RowData.Row.EndOnFrameCodeText}" />                                </Style>                            </dxg:GridColumn.CellStyle>                        </dxg:GridColumn>
<Window x:Class="WpfProject.Views.YWGL.EditDisFrameInfo"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        xmlns:local="clr-namespace:WpfProject.Views.YWGL"       xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"         xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"         xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"           xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"    xmlns:dxet="http://schemas.devexpress.com/winfx/2008/xaml/editors/themekeys"        mc:Ignorable="d"        Title="编辑配线架信息" Height="700" Width="1000" WindowStartupLocation="CenterScreen"  WindowState="Maximized" Loaded="Window_Loaded">    <Window.Resources>        <Style TargetType="{x:Type Button}" x:Key="ButtonStyle">            <Setter Property="Foreground"  Value="Black"/>            <Setter Property="FontFamily" Value="Times New Roman"/>            <Setter Property="FontSize" Value="12"/>        </Style>        <Style TargetType="{x:Type Label}" x:Key="LableLeftStyle">            <Setter Property="HorizontalAlignment" Value="Right"/>            <Setter Property="VerticalAlignment" Value="Center"/>            <Setter Property="FontSize" Value="12" />            <Setter Property="FontWeight" Value="Bold"/>        </Style>        <Style TargetType="{x:Type Label}" x:Key="LableRightStyle">            <Setter Property="HorizontalAlignment" Value="Left"/>            <Setter Property="VerticalAlignment" Value="Center"/>            <Setter Property="FontSize" Value="12" />            <Setter Property="Margin" Value="3,6,0,6"/>        </Style>        <Style TargetType="{x:Type Label}" x:Key="LableBigStyle">            <Setter Property="HorizontalAlignment" Value="Center"/>            <Setter Property="VerticalAlignment" Value="Center"/>            <Setter Property="FontSize" Value="20" />            <Setter Property="FontWeight" Value="Bold"/>        </Style>    </Window.Resources>    <Grid>        <dxlc:GroupBox Header="编辑配线架信息" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">            <Grid>                <Grid.RowDefinitions>                    <RowDefinition Height="35"/>                    <RowDefinition Height="35"/>                    <RowDefinition Height="*"/>                </Grid.RowDefinitions>                <Grid.ColumnDefinitions>                    <ColumnDefinition  Width="*"/>                </Grid.ColumnDefinitions>                <Canvas HorizontalAlignment="Right" Margin="3">                    <dx:SimpleButton x:Name="btnInitPort" Content="初始化端口属性" Width="110" Height="24" Canvas.Right="284" Click="btnInitPort_Click"></dx:SimpleButton>                    <dx:SimpleButton x:Name="btnSetInFrame" Content="批量设置内向配线架" Width="130" Height="24" Canvas.Right="153" Click="btnSetInFrame_Click"></dx:SimpleButton>                    <dx:SimpleButton x:Name="btnAdd" Content="增加" Width="50" Height="24" Canvas.Right="102" Click="btnAdd_Click"></dx:SimpleButton>                    <dx:SimpleButton x:Name="btnUpdate" Content="修改" Width="50" Height="24" Canvas.Right="51" Click="btnUpdate_Click"></dx:SimpleButton>                    <dx:SimpleButton x:Name="btnDel" Content="删除" Width="50" Height="24" Canvas.Right="0" Click="btnDel_Click"></dx:SimpleButton>                </Canvas>                <Label x:Name="lblFrameInfo" Style="{StaticResource LableRightStyle}" Grid.Row="1" Grid.Column="0"></Label>                <dxg:GridControl x:Name="gvDisFramePortList" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"   ItemsSource="{Binding PortList}" >                    <dxg:GridControl.Columns>                        <dxg:GridColumn FieldName="IsValids" Header="选择"  AllowEditing="False" AllowSorting="False"  HorizontalHeaderContentAlignment="Center" VisibleIndex="0" Width="40"  AllowCellMerge="False" >                            <dxg:GridColumn.CellTemplate>                                <DataTemplate>                                    <CheckBox x:Name="cbSelect" IsChecked="{Binding Data.IsValids}"                                     HorizontalAlignment="Center" VerticalAlignment="Center" Checked="cbSelect_Checked"  Unchecked="cbSelect_Unchecked">                                    </CheckBox>                                </DataTemplate>                            </dxg:GridColumn.CellTemplate>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="rn" Width="40"   Header="序号" HorizontalHeaderContentAlignment="Center" ReadOnly="True"   AllowCellMerge="False"  >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="PortID" Header="PortID"  HorizontalHeaderContentAlignment="Center" Width="10" ReadOnly="True" Visible="False"  AllowCellMerge="False"   >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="PortName" Header="端口编号" HorizontalHeaderContentAlignment="Center" Width="80" AllowEditing="False" AllowCellMerge="True">                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="WirTypeName" Header="配线类型"  HorizontalHeaderContentAlignment="Center" Width="120" AllowEditing="False"  AllowCellMerge="False" >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="PortTypeName" Header="端口类型"  HorizontalHeaderContentAlignment="Center" Width="100" AllowEditing="False"  AllowCellMerge="False" >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="EndOnFrameCode" Header="对端配线架编码"  HorizontalHeaderContentAlignment="Center" Width="150" AllowEditing="False"   >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                            <dxg:GridColumn.CellStyle>                                <Style BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=LightweightCellStyle}}" TargetType="{x:Type dxg:LightweightCellEditor}">                                    <Setter Property="ToolTip" Value="{Binding RowData.Row.EndOnFrameCodeText}" />                                </Style>                            </dxg:GridColumn.CellStyle>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="InPortInfo" Header="内向端口配线信息"  HorizontalHeaderContentAlignment="Center" Width="150" AllowEditing="False"  AllowCellMerge="False" >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="OutPortInfo" Header="外向端口配线信息"  HorizontalHeaderContentAlignment="Center" Width="150" AllowEditing="False"  AllowCellMerge="False" >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                        <dxg:GridColumn FieldName="Comments" Header="备注"  HorizontalHeaderContentAlignment="Center" Width="80" AllowEditing="False"  AllowCellMerge="False" >                            <dxg:GridColumn.EditSettings>                                <dxe:TextEditSettings HorizontalContentAlignment="Center" />                            </dxg:GridColumn.EditSettings>                        </dxg:GridColumn>                                            </dxg:GridControl.Columns>                    <dxg:GridControl.View>                        <dxg:TableView  x:Name="tbView"  AllowPerPixelScrolling="True" ShowTotalSummary="True" ShowGroupPanel="False" ScrollingMode="Normal">                                                </dxg:TableView>                    </dxg:GridControl.View>                </dxg:GridControl>            </Grid>        </dxlc:GroupBox>    </Grid></Window>


   /// <summary>        /// 获取配线端口类型信息        /// </summary>        private void GetDisFramePortList()        {            ObservableCollection<CompDisFramePortInfo> PortList = new ObservableCollection<CompDisFramePortInfo>();            string where = " ProjectPreID='" + canshu + "' and FrameID='" + FrameID + "' ";            DataTable dt = portBLL.GetList(where);            if (dt != null && dt.Rows.Count > 0)            {                for (int i = 0; i < dt.Rows.Count; i++)                {                    CompDisFramePortInfo port = new CompDisFramePortInfo();                    port.ID = int.Parse(dt.Rows[i]["ID"].ToString());                    port.PortID = dt.Rows[i]["PortID"].ToString();                    port.PortName = dt.Rows[i]["PortName"].ToString();                    port.FrameID = dt.Rows[i]["FrameID"].ToString();                    port.WirTypeName = dt.Rows[i]["WirTypeName"].ToString();                    port.rn = dt.Rows[i]["rn"].ToString();                    port.PortTypeName = dt.Rows[i]["PortTypeName"].ToString();                    port.EndOnFrameCode = dt.Rows[i]["EndOnFrameCode"].ToString();                    port.EndOnFrameCodeText = dt.Rows[i]["EndOnFrameCodeText"].ToString();                    port.InPortInfo = dt.Rows[i]["InPortInfo"].ToString();                    port.OutPortInfo = dt.Rows[i]["OutPortInfo"].ToString();                    port.Comments = dt.Rows[i]["Comments"].ToString();                    port.rn = dt.Rows[i]["rn"].ToString();                    port.IsValids = selectionItemHelper.GetIsSelected(port.PortID);                    PortList.Add(port);                }                this.gvDisFramePortList.ItemsSource = PortList;            }            else { this.gvDisFramePortList.ItemsSource = null; }        }

using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;namespace WpfProject.Models{ public   class CompDisFramePortInfo    {        ObservableCollection<CompDisFramePortInfo> _portList = new ObservableCollection<CompDisFramePortInfo>();        public ObservableCollection<CompDisFramePortInfo> PortList { get { return _portList; } }        #region Model        private decimal _id;        private string _portid;        private string _portname;        private decimal? _projectpreid;        private string _roomchannelid;        private string _cabinetid;        private string _frameid;        private string _wirtypeid;        private string _wirtypename;        private string _porttypeid;        private string _porttypename;        private string _inportinfo;        private string _outportinfo;        private int? _rank;        private bool _isvalids;        private string _comments;        private string _comment1;        private string _comment2;        private string _comment3;        public string EndOnFrameCode { get; set; }        /// <summary>        ///         /// </summary>        public decimal ID        {            set { _id = value; }            get { return _id; }        }        /// <summary>        ///         /// </summary>        public string PortID        {            set { _portid = value; }            get { return _portid; }        }        /// <summary>        ///         /// </summary>        public string PortName        {            set { _portname = value; }            get { return _portname; }        }        /// <summary>        ///         /// </summary>        public decimal? ProjectPreID        {            set { _projectpreid = value; }            get { return _projectpreid; }        }        public string EndOnFrameCodeText        {            get; set;        }        /// <summary>        ///         /// </summary>        public string RoomChannelID        {            set { _roomchannelid = value; }            get { return _roomchannelid; }        }        /// <summary>        ///         /// </summary>        public string CabinetID        {            set { _cabinetid = value; }            get { return _cabinetid; }        }        /// <summary>        ///         /// </summary>        public string FrameID        {            set { _frameid = value; }            get { return _frameid; }        }        /// <summary>        ///         /// </summary>        public string WirTypeID        {            set { _wirtypeid = value; }            get { return _wirtypeid; }        }        /// <summary>        ///         /// </summary>        public string WirTypeName        {            set { _wirtypename = value; }            get { return _wirtypename; }        }        /// <summary>        ///         /// </summary>        public string PortTypeID        {            set { _porttypeid = value; }            get { return _porttypeid; }        }        /// <summary>        ///         /// </summary>        public string PortTypeName        {            set { _porttypename = value; }            get { return _porttypename; }        }        /// <summary>        ///         /// </summary>        public string InPortInfo        {            set { _inportinfo = value; }            get { return _inportinfo; }        }        /// <summary>        ///         /// </summary>        public string OutPortInfo        {            set { _outportinfo = value; }            get { return _outportinfo; }        }        /// <summary>        ///         /// </summary>        public int? Rank        {            set { _rank = value; }            get { return _rank; }        }        /// <summary>        ///         /// </summary>        public bool IsValids        {            set { _isvalids = value; }            get { return _isvalids; }        }        /// <summary>        ///         /// </summary>        public string Comments        {            set { _comments = value; }            get { return _comments; }        }        public string  rn { get; set; }        public List<CompDisFramePortInfo> CompDisFramePortInfoData { get; set; }        #endregion Model    }}


0 0
原创粉丝点击