当前位置: 首页>>代码示例>>C#>>正文


C# IValueConverter类代码示例

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


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


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