Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all 4964 articles
Browse latest View live

New Post: Why modifying an expandable object doesn't not refresh the content in a PropertyGrid?

$
0
0
Here is my version which does not use binding but instead will use the INotifyPropertyChanged interface of the object being displayed in the property grid to keep the ToString display updated.
public class NotifiedToStringDisplay : ITypeEditor
{
    // ---------------------------------------------------------------------------
    #region Private Properties

    /// <summary>
    /// Get or set the TextBlock used to display the state of the property item.
    /// </summary>
    protected TextBlock DisplayBlock
    {
        get
        {
            if (_DisplayBlock == null)
            {
                _DisplayBlock = new TextBlock();
                _DisplayBlock.Foreground = Brushes.DimGray;
            }

            return _DisplayBlock;
        }
    }
    private TextBlock _DisplayBlock = null;

    /// <summary>
    /// Get or set the current object being displayed.
    /// </summary>
    protected INotifyPropertyChanged CurrentObject
    {
        get { return _CurrentObject; }
        set { _CurrentObject = value; }
    }
    private INotifyPropertyChanged _CurrentObject = null;

    #endregion


    // ---------------------------------------------------------------------------
    #region ITypeEditor Implementation

    /// <summary>
    /// Returns the framework element that is to be used as the editor.
    /// </summary>
    /// <param name="propertyItem">The item being edited.</param>
    /// <returns>A TextBlock that represents the item being edited.</returns>
    public FrameworkElement ResolveEditor(PropertyItem propertyItem)
    {
        if (CurrentObject != null)
        {
            CurrentObject.PropertyChanged -= CurrentObject_PropertyChanged;
        }

        CurrentObject = propertyItem.Value as INotifyPropertyChanged;

        if (CurrentObject != null)
        {
            CurrentObject.PropertyChanged += CurrentObject_PropertyChanged;
        }

        DisplayBlock.Text = propertyItem.Value.ToString();
        return DisplayBlock;
    }

    /// <summary>
    /// Updates the TextBlock being used to represent the property grid item.
    /// </summary>
    /// <param name="sender">The sender of this event.</param>
    /// <param name="e">The event arguments.</param>
    private void CurrentObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        // Avoid problems when properties are updated from non-UI threads
        // by using an action and calling the TextBlock's dispatcher.

        Action<object> updateText = delegate(object obj)
        {
            DisplayBlock.Text = obj.ToString();
        };

        DisplayBlock.Dispatcher.BeginInvoke(updateText, CurrentObject);
    }

    #endregion
}

New Post: PropertyGrid Readonly and Font Color

$
0
0
Interestingly the v2_2 was different and string-Properties were shown in black color. That's what I wanted when I used the PropertyGrid as "ReadOnly". Maybe it is a philosophical question how it should behave. I looked for a way just to show the user some data (that he can't modify) but not in a greyed-out style.
I will have a look at modification of the base styles of the controls.

New Post: PropertyGrid - manage/define subproperties of expanded property

$
0
0
Hi,

I am using the (glorious) PropertyGrid with AutoGenerateProperties set to false.
Each time I change the SelectedObject, I also change the PropertyDefinitions accordingly.

This works great so far, but today I started to use IsExpandable=true in one of my PropertyDefinitions.

The effect was that all subproperties of the expandable property are displayed if I expand it.

Question: can I also add PropertyDefinitions to the PropertyDefinitions collection that define or limit these subproperties? How can I prevent some of the subproperties to appear in the grid?

I tried to add definitions for these subproperties, but they are ignored (probably because the grid expects the PropertyDefinitions to apply to the main properties of the SelectedObject).

New Post: PropertyGrid - manage/define subproperties of expanded property

$
0
0
Hi,

I am using the (glorious) PropertyGrid with AutoGenerateProperties set to false.
Each time I change the SelectedObject, I also change the PropertyDefinitions accordingly.

This works great so far, but today I started to use IsExpandable=true in one of my PropertyDefinitions.

The effect was that all subproperties of the expandable property are displayed if I expand it.

Question: can I also add PropertyDefinitions to the PropertyDefinitions collection that define or limit these subproperties? How can I prevent some of the subproperties to appear in the grid?

I tried to add definitions for these subproperties, but they are ignored (probably because the grid expects the PropertyDefinitions to apply to the main properties of the SelectedObject).



EDIT: Sorry for double-posting!!

New Post: Close drop down button programatically

$
0
0
Hi,

A solution mught be to derive from DropDownButton and override method OnIsKeyboardFocusWithinChanged. If False is received, just close the dropDownButton with IsOpen = false.

Created Unassigned: Why modifying an expandable object doesn't not refresh the content in a PropertyGrid? [21685]

$
0
0
Based on CodePLex discussion https://wpftoolkit.codeplex.com/discussions/351469.

If a propertyItem from an expandable PropertyItem is modified, and the parent PropertyItem uses it in its ToString() method, we should update the parent PropertyItem editor to reflect the modification.

New Post: Why modifying an expandable object doesn't not refresh the content in a PropertyGrid?

Commented Feature: Why modifying an expandable object doesn't not refresh the content in a PropertyGrid? [21685]

$
0
0
Based on CodePLex discussion https://wpftoolkit.codeplex.com/discussions/351469.

If a propertyItem from an expandable PropertyItem is modified, and the parent PropertyItem uses it in its ToString() method, we should update the parent PropertyItem editor to reflect the modification.
Comments: ** Comment from web user: BoucherS **

This will be fixed in v2.7.


Created Unassigned: PropertyGrid - manage/define subproperties of expanded property [21686]

$
0
0
Based on codeplex discussion http://wpftoolkit.codeplex.com/discussions/578597

New Post: PropertyGrid - manage/define subproperties of expanded property

New Post: MessageBox with CheckBox

$
0
0
I need this feature as well, so I've created a derived MessageBox class with a custom template and dependency property. I can display it like so:
var msgbox = new CheckableMessageBox ();
msgbox.ShowDialog();
But it shows only the OK button. How can change the MessageBoxButton in this msgbox instance to display another set of buttons (YesNo/OKCancel/etc) ?

New Post: PropertyGrid - manage/define subproperties of expanded property

Edited Issue: PropertyGrid issue with ValueRangeTextBox [21655]

$
0
0
I am loading an object into the PropertyGrid, and I get the below error. I use the PropertyGrid for many other types, and just one type causes this exception. Doesn't the PropertyGrid only create textboxes for types that it can handle? Is there a way to find out which property/value is causing the exception?

InnerException: System.InvalidCastException
_HResult=-2147467262
_message=Object must implement IConvertible.
HResult=-2147467262
IsTransient=false
Message=Object must implement IConvertible.
Source=mscorlib
StackTrace:
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox.ValueCoerceValueCallback(Object sender, Object value)
at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, Object controlValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, Boolean skipBaseValueChecks)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
at Xceed.Wpf.Toolkit.Primitives.ValueRangeTextBox.OnInitialized(EventArgs e)
InnerException:
Comments: ** Comment from web user: BoucherS **

Hi,

Thanks for clarifying this issue.
It will be fixed in v2.7.
In the meantime, you can go in file Xceed.Wpf.Toolkit/Primitives/ValueRangetextBox,
In method : object ConvertValueToDataType( object value, Type type )
Replace
System.Convert.ChangeType...
by
ChangeTypeHelper.ChangeType...

New Post: MessageBox with CheckBox

$
0
0
Hi,

If you look at MessageBox.OnApplyTemplate() method, there is a call to "ChangeVisualState( _button.ToString(), true );".
This will set the VisualState to use (to good sets of buttons).
In XAML, the MessageBoxTemplate contains the VisualStates for each sets of buttons, modifying their visibility to show them according to the current visualState.
The VisalStates are :
OK
OKCancel
YesNo
YesNoCancel

New Post: MessageBox with CheckBox

$
0
0
Thanks for the tip BoucherS.

I tried to call ChangeVisualState(...) in my derived class but it doesn't change the buttons (Tried in version 2.2).
What does work is calling InitializeMessageBox(...) instead, in which I can specify the buttons and more things that I also need (parent, defaultresult)!

New Post: CheckComboBox

$
0
0
Hi

I'm using the CheckComboBox from this framework in my project and it works fine in VS 2010. However when outside of VS the program crashes. Before i manage to get it work by adding
using Xceed.Wpf.Toolkit in the xaml.cs file but this doesn't work anymore.

New Post: CustomPropertyItems and Custom Editors

$
0
0
Hello,

I am trying to have a PropertyGrid with PropertiesSource set to a Collection of CustomPropertyItem's. I cannot get the definition of a custom editor working.

I have a little application to show the problem... The PropertyGrid on the left works as expected, the one on the right doesn't. If I don't specify the EditorDefinitions it has the values. It seems that the {Binding Value} doesn't work with CustomPropertyItems

Please see the litte test-app:

MainWindow.xaml:
<Window x:Class="PropertyGridTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:PropertyGridTest"       
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow">

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <xctk:PropertyGrid
                SelectedObject="{Binding TestObject}">

                <xctk:PropertyGrid.EditorDefinitions>
                    <xctk:EditorTemplateDefinition>
                    <xctk:EditorTemplateDefinition.TargetProperties>
                        <xctk:TargetPropertyType Type="{x:Type sys:String}" />
                        <xctk:TargetPropertyType Type="{x:Type sys:Int32}" />
                    </xctk:EditorTemplateDefinition.TargetProperties>

                    <xctk:EditorTemplateDefinition.EditingTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Value}" />
                            </DataTemplate>
                        </xctk:EditorTemplateDefinition.EditingTemplate>
                    </xctk:EditorTemplateDefinition>
                </xctk:PropertyGrid.EditorDefinitions>
            </xctk:PropertyGrid>

            <xctk:PropertyGrid
                Grid.Column="1"
                AutoGenerateProperties="False" 
                            PropertiesSource="{Binding Properties}">

                <xctk:PropertyGrid.EditorDefinitions>
                    <xctk:EditorTemplateDefinition>
                        <xctk:EditorTemplateDefinition.TargetProperties>
                            <xctk:TargetPropertyType Type="{x:Type sys:String}" />
                            <xctk:TargetPropertyType Type="{x:Type sys:Int32}" />
                    </xctk:EditorTemplateDefinition.TargetProperties>
                        <xctk:EditorTemplateDefinition.EditingTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Value}" />
                            </DataTemplate>
                        </xctk:EditorTemplateDefinition.EditingTemplate>
                    </xctk:EditorTemplateDefinition>
                </xctk:PropertyGrid.EditorDefinitions>
            </xctk:PropertyGrid>
        </Grid>
</Window>
And the MainWindow.xaml.cs:
using System.Collections.ObjectModel;
using System.Windows;
using Xceed.Wpf.Toolkit.PropertyGrid;

namespace PropertyGridTest
{
    public partial class MainWindow : Window
    {
        public MyTestObject TestObject { get { return new MyTestObject(); } }
        public ObservableCollection<CustomPropertyItem> Properties { get; set; }

        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;

            CreateProperties();
        }

        private void CreateProperties()
        {
            Properties = new ObservableCollection<CustomPropertyItem>();
            Properties.Add(new CustomPropertyItem()
            {
                Description = "StringValue-Description",
                DisplayName = "StringValue",
                Value = "String-Value"
            });
            Properties.Add(new CustomPropertyItem()
            {
                Description = "IntValue-Description",
                DisplayName = "IntValue",
                Value = 5
            });
        }
    }

    public class MyTestObject
    {
        public int IntValue { get; set; }
        public string StringValue { get; set; }

        public MyTestObject()
        {
            IntValue = 5;
            StringValue = "Hello!";
        }
    }
}
Thanks for your help!!
Joerg

Created Unassigned: CustomPropertyItems and Custom Editors [21698]

$
0
0
Based on Codeplex discussion http://wpftoolkit.codeplex.com/discussions/578895

New Post: CustomPropertyItems and Custom Editors

Edited Issue: CustomPropertyItems and Custom Editors [21698]

$
0
0
Based on Codeplex discussion http://wpftoolkit.codeplex.com/discussions/578895
Comments: ** Comment from web user: BoucherS **

This will be fixed in v2.7.

Viewing all 4964 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>