zoukankan      html  css  js  c++  java
  • silverlight 转换器 GLenn

    ConvtoBSfcodeToStr.cs

    namespace SilverlightApplication1
    {
        public class ConvtoBSfcodeToStr : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return (value.ToString().Length < 20 ? value.ToString() : value.ToString().Substring(0,20));
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
    
                return (value.ToString().Length < 20 ? value.ToString() : value.ToString().Substring(0, 20)+"...");
            }
        }  
    }

    xaml:

                         xmlns:localConv="clr-namespace:SilverlightApplication1"
    
                         <localConv:ConvtoBSfcodeToStr x:Key="ConverBStoStr"></localConv:ConvtoBSfcodeToStr>

    使用时 先转换为模板列 Converter={StaticResource ConverBStoStr}

    <data:DataGridTemplateColumn Header="内容" Width="1.0*">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Name="tool"  Text="{Binding ArticleContent, Mode=TwoWay, Converter={StaticResource ConverBStoStr}}">
                                    <ToolTipService.ToolTip>
                                        <ToolTip MaxWidth="500">
                                             <TextBlock Text="{Binding ArticleContent}"  TextWrapping="Wrap"/>
                                        </ToolTip>
                                    </ToolTipService.ToolTip>
                                    </TextBlock>
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>
  • 相关阅读:
    windows系统中ubuntu虚拟机安装及web项目到服务上(二)
    windows系统中ubuntu虚拟机安装及web项目到服务上(一)
    每个配置xml的含义作用
    第三天气接口使用总结
    js模式学习
    mac下php环境配置
    struts2
    MySQL常用命令
    JavaMail邮件开发
    文件上传与下载
  • 原文地址:https://www.cnblogs.com/cuiguangzhi/p/2638104.html
Copyright © 2011-2022 走看看