Giter Site home page Giter Site logo

genericdependencyproperties's People

Contributors

jongleur avatar jongleur1983 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

genericdependencyproperties's Issues

Support DependencyProperty.OverrideMetadata

OverrideMetadata allows to override the default value and handlers for a DependencyProperty for a given class.

Example code:

IsManipulationEnabledProperty.OverrideMetadata(
    typeof(Map),
    new FrameworkPropertyMetadata(true));

A Generic replacement could be implemented as an Extension Method like this:

public void OverrideMetadata<TOwner, TProperty>(
    this DependencyProperty dp,
    GenericFrameworkPropertyMetadata<TProperty, TOwner> metadata)

Generic ZoomPercentageConverter

(see #8)
The Original accepts different TargetTypes, so we might require different implementations here:

Takes a double of returns UnsetValue if it isn't.

If TargetType is double, Convert returns the input value.
If TargetType is object or string the input value is formatted according to some localized string.

Is it possible to define a DependencyPropertyAttribute?

This is only slightly connected to the generics approach of this project, but another followup idea.

Usually a Dependency Property is backed by a common .NET property that uses SetValue() and GetValue in it's accessor methods.

It might be worth to think about an attribute on an auto-property instead, like

[DependencyProperty("propertyName")]
public int BackingProperty { get; set; }

provide overload of RegisterAttached that works with nameof()

An attached DependencyProperty is registered like this:

public static readonly DependencyProperty SomeProperty = DependencyProperty.RegisterAttached(
    "Some",
    typeof(PropertyType),
    typeof(OwnerType)
    );

This property can then be used as in

<NodeOfAnyType OwnerType.Some="valueTypeConvertedToPropertyType" />

As there is no property named "Some" on an attached property as far as I understand it yet, the magic string "Some" keeps to be a string literal in code either - or it can be at least a reference to the DependencyProperty itself as a lambda, that is, it could be registered with a generic signature like this:

public static readonly DependencyProperty SomeProperty = DependencyProperty.RegisterAttached<TPropertyType, TOwnerType>(
    Func<DependencyProperty> depProperty);

Here TPropertyType replaces typeof(PropertyType, TOwnerType replaces typeof(OwnerType) and the Func is used internally to get "SomeProperty" by reflection and to split that to get the desired result.

Note: It will not be possible to CALL the function in the registration method unfortunately as the static field that is returned by the lambda is null and thus calling the lambda and getting the name is not possible - a classical cylcic dependency.

Generic JournalEntryListConverter

(see #8)
Converts a JournalEntryStack to a length-limited list.
Not useful as a generic replacement as it's not intended to be used anywhere else than in the NavigationWindow syle, thus it's kind of internal to WPF.

Generic BooleanToVisibilityConverter

(see #8)

The original takes bool or Nullable and returns a System.Windows.Control.Visibility.
True converts to Visible everything else (null and false) converts to Hidden.
Visible converts to True, everything else converts to False.

For the generic variant I don't know yet how to deal with bool and bool? without losing performance for unnecessary boxing.

Generic AlternationConverter

Converter for #8
Original: System.Windows.Controls.AlternationConverter

  • An additional property stores a list to alternate over
  • Convert: takes an int and returns the corresponding index of the list (taking the modulo)
  • Convert Back: takes an object and returns it's index in the list.

Implement generic variants of the built-in ValueConverters of .NET

http://stackoverflow.com/questions/505397/built-in-wpf-ivalueconverters has this list that could be a starting point (to be converted into single issues in future):

Derived from IValueConverter

  • System.Windows.Navigation.JournalEntryListConverter
  • Xceed.Wpf.DataGrid.Converters.CurrencyConverter
  • Xceed.Wpf.DataGrid.Converters.DateTimeToStringConverter
  • Xceed.Wpf.DataGrid.Converters.GreaterThanZeroConverter
  • Xceed.Wpf.DataGrid.Converters.IndexToOddConverter
  • Xceed.Wpf.DataGrid.Converters.IntAdditionConverter
  • Xceed.Wpf.DataGrid.Converters.InverseBooleanConverter
  • Xceed.Wpf.DataGrid.Converters.LevelToOpacityConverter
  • Xceed.Wpf.DataGrid.Converters.MultimodalResultConverter
  • Xceed.Wpf.DataGrid.Converters.NegativeDoubleConverter
  • Xceed.Wpf.DataGrid.Converters.NullToBooleanConverter
  • Xceed.Wpf.DataGrid.Converters.SourceDataConverter
  • Xceed.Wpf.DataGrid.Converters.StringFormatConverter
  • Xceed.Wpf.DataGrid.Converters.ThicknessConverter
  • Xceed.Wpf.DataGrid.Converters.TypeToBooleanConverter
  • Xceed.Wpf.DataGrid.Converters.TypeToVisibilityConverter
  • Xceed.Wpf.DataGrid.Converters.ValueToMaskedTextConverter

Derived from IMultiValueConverter

  • System.Windows.Controls.BorderGapMaskConverter
  • System.Windows.Navigation.JournalEntryUnifiedViewConverter
  • System.Windows.Controls.MenuScrollingVisibilityConverter
  • Microsoft.Windows.Themes.ProgressBarBrushConverter
  • Microsoft.Windows.Themes.ProgressBarHighlightConverter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.