• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IValueConverter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IValueConverter的典型用法代码示例。如果您正苦于以下问题:C# IValueConverter类的具体用法?C# IValueConverter怎么用?C# IValueConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IValueConverter类属于命名空间,在下文中一共展示了IValueConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetView

        public override View GetView(PropertyInfo property, object o, out BindableProperty targetProperty, out IValueConverter converter)
        {
            targetProperty = Label.TextProperty;
            converter = new ValueConverter();

            return new Label();
        }
开发者ID:shamik94,项目名称:sensus,代码行数:7,代码来源:DisplayYesNoUiProperty.cs


示例2: ChangeObjectValueAction

 public ChangeObjectValueAction(BoundPropertyDescriptor boundPropertyDescriptor, object originalValue, object newValue, IValueConverter stringConverter)
 {
     _boundPropertyDescriptor = boundPropertyDescriptor;
     _originalValue = originalValue;
     _newValue = newValue;
     _stringConverter = stringConverter;
 }
开发者ID:tgjones,项目名称:gemini,代码行数:7,代码来源:ChangeObjectValueAction.cs


示例3: EncryptingValueConverter

 public EncryptingValueConverter(
     IValueConverter decoratedValueConverter,
     IEncryptionAlgorithmFactory encryptionAlgorithmFactory)
 {
     _decoratedValueConverter = decoratedValueConverter;
     _encryptionAlgorithm = encryptionAlgorithmFactory.GetAlgorithm(decoratedValueConverter.Type);
 }
开发者ID:JonOsment,项目名称:XSerializer,代码行数:7,代码来源:EncryptingValueConverter.cs


示例4: GetEnumSource

        public static IEnumerable<EnumMemberInfo> GetEnumSource(Type enumType, bool useUnderlyingEnumValue = true, IValueConverter nameConverter = null, bool splitNames = false, EnumMembersSortMode sortMode = EnumMembersSortMode.Default, Func<string, bool, string> getKnownImageUriCallback = null, bool showImage = true, bool showName = true) {
            var result = enumType.GetFields(BindingFlags.Static | BindingFlags.Public)
                .Where(field => DataAnnotationsAttributeHelper.GetAutoGenerateField(field))
                .Select(field => {
                    Enum value = (Enum)field.GetValue(null);
                    string name = GetEnumName(field, value, nameConverter, splitNames);

                    var imageInfo = GetImageInfo(MetadataHelper.GetAttribute<ImageAttribute>(field), MetadataHelper.GetAttribute<DXImageAttribute>(field), null, getKnownImageUriCallback);
                    ImageSource image = ViewModelBase.IsInDesignMode ? null : (imageInfo.Item1 ?? imageInfo.Item2).With(x => (ImageSource)new ImageSourceConverter().ConvertFrom(x));
                    return new EnumMemberInfo(name, DataAnnotationsAttributeHelper.GetFieldDescription(field), useUnderlyingEnumValue ? GetUnderlyingEnumValue(value) : value, image, showImage, showName,
                     DataAnnotationsAttributeHelper.GetFieldOrder(field));
                });
            switch(sortMode) {
                case EnumMembersSortMode.DisplayName:
                    result = result.OrderBy(x => x.Name);
                    break;
                case EnumMembersSortMode.DisplayNameDescending:
                    result = result.OrderByDescending(x => x.Name);
                    break;
                case EnumMembersSortMode.DisplayNameLength:
                    result = result.OrderBy(x => x.Name.Length);
                    break;
                case EnumMembersSortMode.DisplayNameLengthDescending:
                    result = result.OrderByDescending(x => x.Name.Length);
                    break;
            }
            return result.OrderBy(x => (x.Order != null) ? x.Order : DefaultDisplayOrder).ToArray();
        }
开发者ID:ruisebastiao,项目名称:DevExpress.Mvvm.Free,代码行数:28,代码来源:EnumSourceHelper.cs


示例5: ValueConversionStep

 public ValueConversionStep( Type targetType, IValueConverter valueConverter )
 {
     Arg.NotNull( targetType, nameof( targetType ) );
     Arg.NotNull( valueConverter, nameof( valueConverter ) );
     this.targetType = targetType;
     converter = valueConverter;
 }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:7,代码来源:ValueConversionStep.cs


示例6: CollectionSynchronizer

		public CollectionSynchronizer(INotifyCollectionChanged source, ObservableCollection<object> target, IValueConverter valueConverter)
		{
			_source = source;
			_target = target;
			_valueConverter = valueConverter;
			_source.CollectionChanged += OnSourceCollectionChanged;
		}
开发者ID:taliesins,项目名称:talifun-commander,代码行数:7,代码来源:CollectionSynchronizer.cs


示例7: ValueConverterConvention

 /// <summary>
 /// Constructor 
 /// </summary>
 /// <param name="converter"></param>
 /// <param name="filter"></param>
 public ValueConverterConvention(IValueConverter converter, Func<DependencyProperty, PropertyInfo, bool> filter)
 {
     if (null == converter) throw new ArgumentNullException("converter");
     if (null == filter) throw new ArgumentNullException("filter");
     Converter = converter;
     Filter = filter;
 }
开发者ID:ValdimarThor,项目名称:Cocktail,代码行数:12,代码来源:ValueConverterConvention.cs


示例8: Prompt

 public string Prompt(string message, FlowDocument comment, IValueConverter converter, int length)
 {
     PromptDialog pd = new PromptDialog(App.Current.MainWindow, message, comment, converter, length);
     string r = (bool) ShowDialog(pd) ? pd.Keypad.Text : null;
     pd.Close();
     return r;
 }
开发者ID:kukareka,项目名称:printbox,代码行数:7,代码来源:GuiManager.cs


示例9: SetBinding

 public static BindingExpressionBase SetBinding(this FrameworkElement target, DependencyProperty dp, object source, string path, IValueConverter converter)
 {
     Binding b = new Binding(path);
     b.Source = source;
     b.Converter = converter;
     return BindingOperations.SetBinding(target, dp, b);
 }
开发者ID:saykorz,项目名称:LunarBase,代码行数:7,代码来源:BindingExtensions.cs


示例10: SetBinding

 /// <summary>
 /// Sets a binding from code
 /// </summary>
 /// <param name="element"></param>
 /// <param name="property"></param>
 /// <param name="source"></param>
 /// <param name="path"></param>
 /// <param name="converter"></param>
 public static void SetBinding(FrameworkElement element, DependencyProperty property, object source, string path, IValueConverter converter = null)
 {
     Binding binding = new Binding();
     binding.Source = source;
     binding.Path = new PropertyPath(path);
     binding.Converter = converter;
     element.SetBinding(property, binding);
 }
开发者ID:knowlatest,项目名称:Windows8StartKit,代码行数:16,代码来源:BindingHelper.cs


示例11: GetRedactFunc

 private static Func<bool, object, string> GetRedactFunc(IValueConverter valueConverter)
 {
     return
         (redactEnabled, value) =>
             redactEnabled
                 ? "XXXXXXXXXX"
                 : valueConverter.GetString(value, null);
 }
开发者ID:JonOsment,项目名称:XSerializer,代码行数:8,代码来源:ValueTypes.cs


示例12: CommandForMethod

 /// <summary>
 /// Initializes a new instance of <see cref="CommandForMethod"/>
 /// </summary>
 /// <param name="target">Target to bind to for the method, typically a ViewModel</param>
 /// <param name="methodName">Name of the method to bind to</param>
 /// <param name="canExecuteWhen">Optionally a reference to either a property or method that gets called to check if the command can execute</param>
 /// <param name="parameterConverter">Optionally a <see cref="IValueConverter"/> that will be used for converting value to the method</param>
 /// <remarks>
 /// The canExecuteWhen parameter can take the name of a property or a method. If it is 
 /// a property and the declaring type implements <see cref="INotifyPropertyChanged"/>,
 /// it will honor that and actually fire off the CanExecuteChanged if the property changes
 /// state. The property needs to be of type boolean, and a method can take one parameter,
 /// and the CommandParameter property from the view will be the content if so. The method
 /// needs to return a boolean.
 /// </remarks>
 public CommandForMethod(object target, string methodName, string canExecuteWhen = null, IValueConverter parameterConverter = null)
 {
     _target = target;
     _canExecuteWhen = canExecuteWhen;
     _parameterConverter = parameterConverter;
     GetMethod(target, methodName);
     if (!string.IsNullOrEmpty(canExecuteWhen)) SetupCanExecuteWhen(target, canExecuteWhen);
 }
开发者ID:LenFon,项目名称:Bifrost,代码行数:23,代码来源:CommandForMethod.cs


示例13: SimpleValueType

        public SimpleValueType(Type type, IValueConverter valueConverter)
            : base(type)
        {
            if (valueConverter == null)
                throw new ArgumentNullException("valueConverter");

            this.ValueConverter = valueConverter;
        }
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:8,代码来源:SimpleValueType.cs


示例14: DefaultRunnableFactory

 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultRunnableFactory"/> class.
 /// </summary>
 public DefaultRunnableFactory(IEnumerable<Type> availableRunnables, IValueConverter valueConverter = null, INameMatcher runnableNameMatcher = null, INameMatcher parameterNameMatcher = null,
                               IServiceFactory serviceFactory = null)
 {
     AvailableRunnables = availableRunnables ?? Enumerable.Empty<Type>();
     RunnableNameMatcher = runnableNameMatcher ?? new EqualityNameMatcher();
     ParameterNameMatcher = parameterNameMatcher ?? new EqualityNameMatcher();
     ValueConverter = valueConverter ?? new EmptyValueConverter();
     ServiceFactory = serviceFactory;
 }
开发者ID:szabototo89,项目名称:CodeSharper,代码行数:12,代码来源:DefaultRunnableFactory.cs


示例15: CustomBinding

        public CustomBinding(string propertyName, object dataSource, string dataMember, IValueConverter valueConverter, object converterParameter = null)
            : base(propertyName, dataSource, dataMember)
        {
            if (valueConverter != null)
                this._converter = valueConverter;

            this._converterCulture = Thread.CurrentThread.CurrentUICulture;
            this._converterParameter = converterParameter;
        }
开发者ID:oswellchan,项目名称:PowerPointLabs,代码行数:9,代码来源:CustomBinding.cs


示例16: CreateOneWayBinding

        /// <summary>
        /// Creates a new <see cref="Binding"/> using <paramref name="bindingSource"/> as the <see cref="Binding.Source"/>,
        /// <paramref name="propertyPath"/> as the <see cref="Binding.Path"/>,
        /// and <paramref name="converter"/> as the <see cref="Binding.Converter"/>.
        /// </summary>
        /// <param name="bindingSource">The object to use as the new binding's <see cref="Binding.Source"/>.</param>
        /// <param name="propertyPath">The property path to use as the new binding's <see cref="Binding.Path"/>.</param>
        /// <param name="converter">The converter to use as the new binding's <see cref="Binding.Converter"/>.</param>
        /// <returns>A new <see cref="Binding"/> object.</returns>
        public static Binding CreateOneWayBinding(this INotifyPropertyChanged bindingSource, string propertyPath, IValueConverter converter) {
            Binding binding = new Binding();

            binding.Source = bindingSource;
            binding.Path = new PropertyPath(propertyPath);
            binding.Converter = converter;

            return binding;
        }
开发者ID:slieser,项目名称:sandbox,代码行数:18,代码来源:DataBindingExtensions.cs


示例17: Build

        internal static Binding Build(object source, string path, IValueConverter converter = null)
        {
            var binding = new Binding();
            binding.Source = source;
            binding.Path = new PropertyPath(path);
            binding.Converter = converter;

            return binding;
        }
开发者ID:nharren,项目名称:MusicTimeline,代码行数:9,代码来源:BindingBuilder.cs


示例18: SetBinding

        public static BindingExpressionBase SetBinding(DependencyObject target, DependencyProperty targetProperty, DependencyObject source, DependencyProperty sourceProperty, BindingMode mode, IValueConverter converter)
        {
            Binding binding = new Binding(sourceProperty.Name);
            binding.Source = source;
            binding.Converter = converter;
            binding.Mode = mode;

            return BindingOperations.SetBinding(target, targetProperty, binding);
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:9,代码来源:BindingHelper.cs


示例19: GetView

        public override View GetView(PropertyInfo property, object o, out BindableProperty targetProperty, out IValueConverter converter)
        {
            targetProperty = Editor.TextProperty;
            converter = new ValueConverter();

            return new Editor
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
        }
开发者ID:shamik94,项目名称:sensus,代码行数:10,代码来源:EditableListUiProperty.cs


示例20: GetView

        public override View GetView(PropertyInfo property, object o, out BindableProperty targetProperty, out IValueConverter converter)
        {            
            targetProperty = Switch.IsToggledProperty;
            converter = null;

            return new Switch
            {
                HorizontalOptions = LayoutOptions.Start
            };
        }
开发者ID:shamik94,项目名称:sensus,代码行数:10,代码来源:OnOffUiProperty.cs



注:本文中的IValueConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IValueProvider类代码示例发布时间:2022-05-24
下一篇:
C# IValueContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap