Giter Site home page Giter Site logo

propertytools's Introduction

License Project page NuGet Gitter chat Build artifacts

Control Description Status
PropertyGrid A control that shows properties of an object or a collection of objects. Stable
DataGrid A data grid with an "Excel feel" (note that the control is not virtualized) Stable
TreeListBox A ListBox that looks and feels like a TreeView (supports multi-select and drag-drop) Stable
ColorPicker A color picker Stable
RadioButtonList A collection of radio buttons that binds to an enum Stable
EnumMenuItem A collection of checkable menuitems that binds to an enum Stable
EditableTextBlock A TextBlock that can be changed into a TextBox, useful for in-place editing in TreeViews Stable
FilePicker A TextBox with browse for file button Stable
DirectoryPicker A TextBox with browse for directory button Stable
DockPanelSplitter A splitter for DockPanels Stable
SpinControl A numeric up/down spinner control Stable
LinkBlock A hyperlink on a TextBlock Stable
SliderEx A Slider that calls IEditableObject.BeginEdit/EndEdit when thumb dragging Stable
TextBlockEx A TextBlock that contains a style for disabled state Stable
PopupBox A restyled ComboBox where you can put anything in the popup view Stable
FormattingTextBox A TextBox where you can bind the formatting string Stable

PropertyGrid

PropertyGrid

DataGrid

DataGrid

TreeListBox

TreeListBox

ColorPicker

ColorPicker ColorPicker

Supported frameworks

  • Microsoft .NET 4.6.2 or later
  • Microsoft .NET 6

Supported build environments

  • Visual Studio 2022

propertytools's People

Contributors

aldinei-sampaio avatar cmoha avatar cpyfferoen avatar danielchalmers avatar decode-cody avatar dtwk1 avatar gotdibbs avatar jogibear9988 avatar johnsonlu avatar jonarw avatar kiwamaru avatar mitch-connor avatar objorke avatar pium-arc avatar raylu1 avatar rolandkoenig avatar sainyam2003 avatar steinarmalin avatar travisro avatar verybadsoldier avatar woodlandhunter avatar zhzg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

propertytools's Issues

PropertyGrid: Refactor property model

This issue was imported from CodePlex

objo wrote 2014-03-28 at 15:06
Refactor the PropertyItem class - there is too much responsibility in this class.

objo wrote 2014-03-29 at 13:13
I suggest to add specialized classes for different functionalities, e.g.

  • TextPropertyItem (shown as text box)
  • SliderPropertyItem (shown as slider)
  • SpinnerPropertyItem (shown as text box with spin up/down buttons)
  • DataGridPropertyItem (shown as data grid)
  • FilePathPropertyItem (shown as file picker)
  • DirectorypathPropertyItem (shown as directory picker)
  • SelectorPropertyItem (shown as combo box or list box)
  • PasswordProperyItem
  • ImagePropertyItem (shown as image)
  • LabelPropertyItem (shown as label/text block)

some of the properties must still be in the base class PropertyItem:

  • display name
  • description
  • header style
  • enable/disable
  • visibility
  • readonly
  • font (family, size, weight)
  • converter
  • "auto update text" (consider rename)

Select cells and toggle check box

Given a datagrid with a string column and a bool column.
Select a row and toggle a checkbox in the bool column.
Expected behavior: string value changed to true or false, and checkbox toggled
Actual behavior: no change

Dragging fails

This issue was imported from CodePlex

nightst4r wrote 2013-05-10 at 06:19
Tree Example:

Root

  • ObjA
  • ObjB
  • + Obj1
  • + Obj2
    • Obj3
If you try to drag ObjectA past Obj3, the system tries to get clever and move A past B @Level 1.

But, instead, since you are removing ObjectA, it becomes a "disconnected item" then when you attach to ObjecB, it sees that you're trying to go past the end of it, so it tries to find the nearest sibling... it ends up finding the "disconnected
item" And then tries to find the index of that, which is -1. That then fails to re-attach the object.

I actually didn't like it trying to go up a level anyway, so my work around simply disables it ( see below ).

This feature doesn't really work well since you are moving the location in the view model, when the model may have already positioned the item for you in the correct location. In my case, the Model drives the View Model, Dragging my nodes makes changes to the
model, not to the view model, so this was actually fighting me =)

My Work around is to prevent the passing up instead I attach the node at the end:

In TreeListBox.cs: (line 307)


 case NotifyCollectionChangedAction.Add:
                    if (parent.IsExpanded)
                    {
                        int i;
                        if (e.NewStartingIndex + e.NewItems.Count < parent.Children.Count)
                        {
                            // inserted items
                            var followingChild = parent.Children[e.NewStartingIndex + e.NewItems.Count];
                            i = this.Items.IndexOf(followingChild);
                        }
                        else
                        {
                            // inserted items
                            i = this.Items.Count;

                            /* This is buggy in the case of "disconnected items"
                            // added items
                            var parentSibling = parent.GetNextSibling();
                            if (parentSibling == null)
                            {
                                // No sibling found, so add at the end of the list.
                                i = this.Items.Count;
                            }
                            else
                            {
                                // Found the sibling, so add the items before this item.
                                i = this.Items.IndexOf(parentSibling.Content);

                                //// int i0 = this.ItemContainerGenerator.IndexFromContainer(parentSibling);
                            }*/
                        }

objo wrote 2013-06-08 at 08:14
Thanks for the code, I am aware of some problems with the TreeListBox control. I think the preparation of the containers (PrepareContainerForItemOverride)is also part of the problems. I am planning to look into this after the summer!

Also see https://github.com/dg9ngf/MultiSelectTreeView (this is a custom control, not based on TreeView or ListBox).

nightst4r wrote 2013-06-08 at 19:04
Thanks for the link! The only major problem I see with the dg9ngf link is that it doesn't seem to have drag and drop. I am using that pretty heavily at the moment to move nodes around. Currently I think i have most of the kinks worked out with custom code,
I haven't seen it mis-behave in a while now.

objo wrote 2013-06-09 at 10:30
Also see https://treeviewex.codeplex.com which supports drag and drop

NullReferenceException problem in WindowsBase.dll when I run PropertyGridDemo with Debug mode.

I've just cloned the latest version of PropertyTools and tried to run PropertyGridDemo with "Debug" mode.
After clicking some examples on left tab, NullReferenceException was occured like this.

image

Sorry for Korean language and it might be...

An unhandled exception of type 'System.NullReferenceException' occurred in WindowsBase.dll
Additional information: Object reference not set to an instance of an object.

I think that it might be a simple error, and I'm just expecting that this error will be fixed as soon.

unusual behavior

I previously used ver 2014.1.29.1 Recently I updated to version 2015.1.34.0. With the latest version installed in my project --- any class where I had a reference to both:
System.ComponentModel
PropertyTools.DataAnnotations
an error is thrown for every property that has an annotation.
The error reports that the BrowsableAttribute or the DisplayNameAttribute is ambiguous.
This was not the case in the older version.
The solution for me was to remove the reference to System.ComponentModel, on every class that includes PropertyTools but it is not clear that someone may use some part of System.ComponentModel that is not included in PropertyTools.DataAnnotations. In any case, for a large project the upgrade requires a lot of hand work when thousands of errors are thrown accompanying the upgrade, so it would probably be nice for others if the ambiguous situation were resolved.

DataGrid: Insert row above/below

This issue was imported from CodePlex

objo wrote 2014-04-10 at 14:18
In the row context menu, change "Insert row" to "Insert row above". Add "Insert row below"

Similary for columns: "Insert column before", "Insert column after"

This is done in Google spreadsheets, but not in Excel.

PropertyGrid: Change UpdateSourceTrigger using DataAnnoation

This issue was imported from CodePlex

Blacal wrote 2013-06-07 at 06:10
I need to configure most of my properties with "UpdateSourceTrigger.PropertyChanged". Is this possible in any way using the current API?

If not, i would propose a new Attribute int the PropertyTools.DataAnnotations namespace called something like "UpdateSourceTriggerAttribate" which allows to change this.

objo wrote 2013-06-08 at 08:04
There is a AutoUpdateText attribute, but this only work for properties using TextBox controls.

Could UpdateOnPropertyChanged be a better name? This could be used for all types of controls.

Unable to create a control for a TimeSpan in DefaultPropertyControlFactory

A TimeSpan property is passed to the DefaultPropertyControlFactory as a string.
I'd however like my TimeSpans to be configured by a user control, so is it possible to make TimeSpans pass on as a PropertyItem with ActualPropertyType == typeof(TimeSpan) and have them handled by at method like protected virtual FrameworkElement CreateTimeSpanControl(PropertyItem property)?

Enable/disable property by radio button

Add an attribute that defines that the header should be a radio button that is bound to a property that enables/disables the decorated property.

e.g.

        public enum Country { None, Argentina, Bolivia, Chile }

        [Browsable(false)]
        public Country CountrySelector { get; set; }

        [Category("Countries")]
        [EnableByRadioButton("CountrySelector", Country.None)]
        [Comment]
        [DisplayName("None")]
        public string NoneDummy { get { return string.Empty; } }

        [EnableByRadioButton("CountrySelector", Country.Argentina)]
        public string Argentina { get; set; }

        [EnableByRadioButton("CountrySelector", Country.Bolivia)]
        public string Bolivia { get; set; }

        [EnableByRadioButton("CountrySelector", Country.Chile)]
        public string Chile { get; set; }

image

NuGet Package not doing complete "install"

I've been trying to upgrade from a rather old version of PropertyTools.WPF to the one published on NuGet, but have run in to a slight problem.

PropertyTools.Wpf.dll is depending on PropertTools.dll, but the later one isn't added as a reference to the projects that uses PropertyTools.Wpf which results in a assembly load failure.

Shouldn't PropertTools.dll be added as a reference by the NuGet manager?

TreeListBox Having Issues Adding Children Properly

DirectoryDemo

As you can see the only Directory that I have open is T:, however all the folders inside that directory are not being added below and is instead being added at the bottom. I have been having this issue with my own code but figured it would be best to show you with one of the examples.

Adding a larger amount of items leads to an ArgumentException

When expanding all Items of a TreeListBox with many items (e.g. > 10,000) and scrolling in it an Exception occurs: ArgumentException: Height must be non-negative

Reproduce:

  1. In TreeListBoxDemo.MainViewModel ctor:
    change AddRecursive to n = 5, levels = 5
  2. Scroll

Support for Datatable (work in progress,discussions)

I'm currently again looking to support DataTable.

For this I think the List Strategy generate Columnsshould be changed to smth. like this:

 var view = CollectionViewSource.GetDefaultView(this.ItemsSource);
            var iitemProperties = view as IItemProperties;
            if (iitemProperties != null)
            {
                foreach (var info in iitemProperties.ItemProperties)
                {
                    Owner.ColumnDefinitions.Add(
                        new ColumnDefinition
                        {
                            Descriptor = info.Descriptor as PropertyDescriptor,
                            Header = info.Name,
                            HorizontalAlignment = Owner.DefaultHorizontalAlignment,
                            Width = Owner.DefaultColumnWidth
                        });
                }

                return;
            }

what do you mean?

PropertyGrid: make property panel resizable

This issue was imported from CodePlex

DivNishi wrote 2012-05-07 at 10:58
Property panel is resizable everywhere on the PropertyControl, while dragging using mouse over the left corner of the control user can maximize or minimize the control, or control can be moved out from the screen. Look at the attachment, using latest version
of PropertyTools.Wpf

PropertyGrid: Support scaffolding

This issue was imported from CodePlex

mwisnicki wrote 2012-02-13 at 22:49
NuGet packages can register powershell commands, for example there is a MvcScaffolding nuget for ASP.NET MVC.

It would be nice if your nuget came with something like PropertyGrid-Scaffold command that for given class would produce static XAML equivalent to what would be generated at runtime by PropertyGrid. In other words it should create in-memory instance of PropertyGrid
for given class and dump visual tree to Xaml file (with some processing).

objo wrote 2012-02-14 at 05:11
Cool idea :) But when you have converted to the static XAML you won't need the PropertyControl (and probably not the assembly, so it should be removed). Then I think this should be a visual studio extension, and not included in the nuget package!

mwisnicki wrote 2012-02-14 at 08:44
VS extensions do not work with Express editions while NuGet does to a certain extent. Both can be provided of course. I think it is also possible to add context menu item in designer to transform PropertyControl into plain XAML.

While such transformation would get rid of PropertyControl, removing whole assembly is not really an option - many uses of it will and should remain, like your type specific editors (color pickers etc.).

Insert and interpolate

This issue was imported from CodePlex

objo wrote 2014-06-27 at 14:10
Make it possible to interpolate values when inserting new rows/columns.

Option 1: Add property to DataGrid that defines if this is active or not

Option 2: Add new items in the row/column context menu "Insert interpolated row", "Add extrapolated row" etc.

How to set Group.Icon / PropertyIcon dynamically?

I want to set the Group.Icon-Property dynamically. Not a static icon for all categories, it should be individually fo every group/category. I found the PropertyIcon but no Attribute to set it. Any hints?

Build errors with code downloaded

I'm getting build errors when I downloaded the sourcecode.

The tag 'ColorToBrushConverter' does not exist in XML namespace 'clr-namespace:PropertyTools.Wpf;assembly=PropertyTools.Wpf'. Line 9 Position 10. C:\Users\rdoshi\Downloads\PropertyTools-master\PropertyTools-master\Source\Examples\Controls\ControlDemos\Pages\ColorPickerPage.xaml

It is giving similar errors for all the controls. What am I missing ?

Doesn't update columns when ObservableCollection<ObservableCollection<T>> change

Hello,

I have some data in a 2D ObservableCollection (ObservableCollection<ObservableCollection<double>>) that can change. When that data change it could have more o less rows and columns, the problem is that the rows get updated but columns don't.

Below is the WPF code I use. I verified that all the bindings are correct, and the item source change correctly.

<pt:DataGrid x:Name="CoefficientMatrix"
             ItemsSource="{Binding CoefficientMatrix}"
             ColumnHeadersSource="{Binding CoefficientMatrixColumnHeaders}"
             RowHeadersSource="{Binding CoefficientMatrixRowHeaders}"
             VerticalAlignment="Stretch"
             HorizontalAlignment="Stretch"
             ScrollViewer.CanContentScroll="True"
             ScrollViewer.HorizontalScrollBarVisibility="Auto"
             CanInsert="False"
             CanDelete="False"
             CanResizeColumns="True"
             AutoSizeColumns="True"
             Margin="10"
             Background="White" />

Thanks.

Binding does not work on a regular non mvvm wpf project

This issue was imported from CodePlex

BlackDogSpark wrote 2014-08-04 at 21:56
It seems that binding does not work if one does not use mvvm. All other bindings in my projects works just fine, but I cant get selectedobject or selectedobjects in propertygrid to work in any non mvvm project to work.

objo wrote 2014-08-06 at 12:29
The SelectedObject(s) properties are standard dependency properties. It should not matter if data binding is used or not. Can you provide an example that reproduces the problem?

BlackDogSpark wrote 2014-08-10 at 18:22
Okay the binding works now. I just missed one line of code in my app.

Thanks for the exelent controls!

Support for date format dd/MM/yyyy

I tried the StringFormat "dd/MM/yyyy" on a date property and the propertygrid shows the date correctly formatted. However, when I enter the value "04/10/2014" for the property, it gets converted to "10/04/2014". Seems like the stringformat dont work as well for input as it works for output the current value.

I am having throuble to understand how the PropertyGrid manages the StringFormat property. I found a timespan converter, but couldnot find any datetimeconverter. If someone can get me some hint on how that feature works, I can try to figure out a fix.

PropertyGrid Example: fails on selection of any sample

Hello!
If I select anything in the left pane or click on any menu item in "PropertyGrid" menu then app fails with NullReferenceException in MS.Internal.AvTrace.AntiFormat(string s).
StackTrace:

   at MS.Internal.AvTrace.AntiFormat(String s)
   at MS.Internal.AvTraceBuilder.AppendFormat(String message, String arg1, String arg2)
   at MS.Internal.TraceData.DescribeSourceObject(AvTraceBuilder traceBuilder, Object o)
   at MS.Internal.TraceData.DescribeTarget(AvTraceBuilder traceBuilder, DependencyObject targetElement, DependencyProperty targetProperty)
   at MS.Internal.TraceData.Describe(AvTraceBuilder traceBuilder, Object o)
   at MS.Internal.TraceData.OnTrace(AvTraceBuilder traceBuilder, Object[] parameters, Int32 start)
   at MS.Internal.AvTrace.Trace(TraceEventType type, Int32 eventId, String message, String[] labels, Object[] parameters)
   at MS.Internal.TraceData.Trace(TraceEventType type, AvTraceDetails traceDetails, Object p1)
   at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
   at MS.Internal.Data.DataBindEngine.Run(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at PropertyGridDemo.App.Main() in c:\Users\pavel.platto\Desktop\PropertyTools-master\Source\Examples\PropertyGrid\PropertyGridDemo\obj\Debug\App.g.cs:line 0
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Remove ConverterAttribute

This issue was imported from CodePlex

objo wrote 2014-03-28 at 15:05
Remove dependencies to PresentationCore in the test library.

Register converters in the control.

Auto-insert rows when auto-filling

This issue was imported from CodePlex

objo wrote 2014-06-27 at 14:17
It should be possible to add rows when using the auto-fill feature.

Example:

  1. DataGrid with two rows.
  2. Select the two rows
  3. Drag the auto-fill rectangle to cover 10 rows

Expected: 8 rows will be added.

Actual: not possible to drag below the existing rows

Binding does not work on SelectedObjects of PropertyGrid.

This issue was imported from CodePlex

labstyrotentasto wrote 2014-08-15 at 09:55
I'm working with the property 'SelectedObjects' of PropertyGrid.

My code is so simple, but binding does not work.

On Debug mode, I can see that SelectedObjects of propertygrid has some items chosen, but I cannot see the properties on the control.

Is there anything I missed?

The code is...

-- .xaml --


        

-- .cs --

SelectedModels = new ObservableCollection();

...

/// 
/// Gets selected models.
/// 
public ObservableCollection SelectedModels { get; private set; }

objo wrote 2014-08-15 at 14:36
I think this should be posted under discussion, if it is not a bug or a feature request.

You also need to show what kind of objects you are adding to the collection, this is probably where the problem is.

labstyrotentasto wrote 2014-08-17 at 07:36
I added some codes in 'PropertyGrid.cs' as follows.

/// 
/// Handles changes in SelectedObjects.
/// 
/// The  instance containing the event data.
private void SelectedObjectsChanged(DependencyPropertyChangedEventArgs e)
{
    if (e.OldValue != null)
    {
        INotifyCollectionChanged collection = e.OldValue as INotifyCollectionChanged;
        if (collection != null)
            collection.CollectionChanged -= new NotifyCollectionChangedEventHandler(SelectedObjects_CollectionChanged);

        NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, e.OldValue as IList);
        SelectedObjects_CollectionChanged(e.NewValue, args);
    }

    if (e.NewValue != null)
    {
        INotifyCollectionChanged collection = e.NewValue as INotifyCollectionChanged;
        if (collection != null)
            collection.CollectionChanged += new NotifyCollectionChangedEventHandler(SelectedObjects_CollectionChanged);

        NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, e.NewValue as IList);
        SelectedObjects_CollectionChanged(e.NewValue, args);
    }
    else
        this.CurrentObject = null; 
}

List selectedObjects = new List();
void SelectedObjects_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
    switch (e.Action)
    {
        case NotifyCollectionChangedAction.Add:
            foreach (var item in e.NewItems)
            {
                if (!selectedObjects.Contains(item))
                    selectedObjects.Add(item);
            }
            break;

        case NotifyCollectionChangedAction.Remove:
            foreach (var item in e.OldItems)
            {
                if (selectedObjects.Contains(item))
                    selectedObjects.Remove(item);
            }
            break;

        case NotifyCollectionChangedAction.Reset:
            selectedObjects.Clear();
            break;

        default:
            break;
    }

    if (selectedObjects.Count == 0)
        this.CurrentObject = null;
    else if (selectedObjects.Count == 1)
        this.CurrentObject = selectedObjects[0];
    else
        this.CurrentObject = new ItemsBag(selectedObjects);

    this.UpdateControls();
}

I'm not sure that this is the best solution, but it works well in my case.

Error messages are not (easily) localizable

I am trying to create an application in multiple languages, and I am using System.ComponentModel.DataAnnotations.CustomValidation to make a custom validator. The strings delivered in my ValidateionResult are however not localizable, or at least I can see no easy way to localize it.
I need to keep my localization away from my property classes, so it would be awesome if it could be done in my custom PropertyItemFactory in a method named GetLocalizedErrorMessage or something similar.

Behavior when changing value in selection

Change behavior when changing value to a selection of cells that are bound to different types
Alternative 1: change value if possible
Alternative 2: change no values
Alternative 3: change only cells that are bound to the same data type as the cell edited

ColorPicker: converter exception

This issue was imported from CodePlex

objo wrote 2011-11-26 at 19:07
The color picker gets a red border before picking the first color.

Could it be a null reference exception in one of the converters?

PerMalmberg wrote 2012-03-17 at 14:35
Hello Objo,

I'm not sure if this is related or not, but I'm currently upgrading my project to use the ColorPicker2 and thus needed a DrawingColorToNullableMediaColorConverter (attached).

One thing I noticed is that when the first color is about to be selected, the ColorPicker tries to set the color to null, despite having read current color from the model. I therefore had to handle this in the converter (else-cause in the Convert-method) otherwise
the PropertyChanged-notification would end up with the color white being selected.

I doubt this behavior is intended, comments?

PerMalmberg wrote 2012-03-17 at 14:45
Sorry, made a typo: I meant the if( col == null ) -condition, not the else-clause

objo wrote 2012-03-17 at 19:08
Yes, this behavior is not intended - but I have not figured out the source of this problem (maybe some of the controls inside the ColorPicker2 are 'fighting'?)

I think the converter from System.Drawing.Color (GDI+) to System.Window.Media.Color (WPF) should be in the client application, not in the PropertyTools.Wpf library. Only WPF assemblies should be referenced since this is a WPF library.

objo wrote 2014-04-10 at 14:42
Is this solved? I have not noticed it recently.

Error: Could not find file or assembly

I will get this error of my propertyGrid:
Error 1 Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. Das System kann die angegebene Datei nicht finden.

WPF Ext. Toolkit support

I'm thinking about support for more Editors in the Datagrid!
(DateTime, TimeSpan, Brush, UpDowns (Decimal,Integer,..))
by including Ext.Wpf Toolkit.

I've a fork of it at github: https://github.com/dotnetprojects/WpfExToolkit

It's okay when i create a Extension DLL with a new DataGridControlFactory wich uses additional Controls? Will it be possible to include this DLL to the main Project?

DataGrid: Edit column and row headers

This issue was imported from CodePlex

objo wrote 2014-02-04 at 14:25
Make it possible to edit the column and row headers in the DataGrid control.

Add properties

bool EditableColumnHeaders
bool EditableRowHeaders

To start editing a header cell:

  • Mouse click
  • Press key e.g. Ctrl+F2, Ctrl+Shift+F2, Alt+F2?
  • Right click on header and select "Edit"

PropertyGrid not visible in vs2012 Xaml designer

This issue was imported from CodePlex

BlackDogSpark wrote 2014-08-01 at 11:16
I created a new wpf project and added the references and xaml tag. The xaml designer gives the following message:

FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.

When I compile the project it works just fine. Also the PropertyTools samples work normally and the grid is visible in the xaml designer.

Maeby this is related to the fact that I'm not using mvvm.

BlackDogSpark wrote 2014-08-01 at 11:45
The problem went away when I cloned the source and added PropertyTools.Wpf_NET40 and PropertyTools_PCL project to my solution.

objo wrote 2014-08-06 at 12:27
Do you have the latest VS updates installed? I think this is a bug in VS XAML designer and not in the PCL library.

Prevent invalid data from being assigned to the property

I have some validations I need to do in my properties, like:

  • Required (should not be null or empty string)
  • Regex (entered text must follow a predefined regex pattern)
  • Range (max and min values for numeric properties)

I successfully managed to configure my class as the PropertyGrid validates and displays error messages for all of those conditions. However, I had not found a way to prevent the PropertyGrid from assigning the invalid values to the property.

Example: In the "DataAnnotations" example of PropertyGridDemo, there is a property nammed "RequiredString". If I delete the contents of the textbox, the PropertyGrid shows the error message, but the empty string was already assigned to the property. That's easy to reproduce as follows:

In the TestBase class, add this method:

    protected void RaisePropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

And in the TestDataAnnotations class, change this code:

    [Required(AllowEmptyStrings = false, ErrorMessage = "A value is required.")]
    public string RequiredString { get; set; }

For this:

    private string _requiredString;
    [Required(AllowEmptyStrings = false, ErrorMessage = "A value is required.")]
    public string RequiredString
    {
        get
        {
            return _requiredString;
        }
        set
        {
            if (value != _requiredString)
            {
                _requiredString = value;
                RaisePropertyChanged("RequiredString");
                RaisePropertyChanged("CurrentRequiredString");
            }
        }
    }

    public string CurrentRequiredString
    {
        get
        {
            return _requiredString;
        }
    }

Now, when the user clears the contents of "RequiredString" textbox, the "CurrentRequiredString" textbox is also cleared.

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.