Comments (4)
Hi,
Instead of using the IsExpandingNonPrimitiveTypes, which will make all possible subItem expandable, you can set the
[ExpandableObject()] attribute over the object you want to see as expandable:
<xctk:PropertyGrid Grid.Row="1"
x:Name="_propertyGrid"
Width="450"
MaxHeight="650"
Margin="10"
SelectedObject="{Binding}"
ShowDescriptionByTooltip="True"
IsExpandingNonPrimitiveTypes="False">
</xctk:PropertyGrid>
this.DataContext = new Player() { Infos = new Infos() { FirstName = "Kyle", LastName = "Matheson" }, Infos2 = new Infos2() { ThirdName = "John", FourthName = "Mike" }, Position = "Center" };
public class Player
{
[ExpandableObject()] //Only Infos will be expandable
public Infos Infos { get; set; }
public Infos2 Infos2 { get; set; }
public string Position { get; set; }
}
public class Infos
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class Infos2
{
public string ThirdName { get; set; }
public string FourthName { get; set; }
}
from wpftoolkit.
Thank's for your answer.
I've another problem: the function ExpandendProperty doesn't work.
In the PropGrid class, I have a property named 'Fondazione' with the attribute 'RefreshProperty.All'. When the refresh is triggered, all properties in the PropertyGrid are collapsed, even if they were not collapsed before. To resolve this issue and maintain the appearance of the PropertyGrid unchanged, I thought about raising an event (OnBeforeFondazioneChanged) before the refresh and saving the expanded properties in a List. Then, after the refresh, the function PropertyValueChanged is called, which should expand each property in the list using ExpandProperty, but this does not work. The list is correctly populated, and it seems that ExpandProperty is specifically what is not working. I made an attempt where instead of calling ExpandProperty I call ExpandAllProperties, and this expands all the properties.
public List ExpandedProp;
public MainWindow()
{
InitializeComponent();
var pGrid=new PropGrid();
pGrid.Fondazione=false;
....
pGrid.svincoloI=new SvincoloI();
pGrid.svincoloJ=new SvincoloJ();
pGrid.armaturaInf=new Armatura();
pGrid.armaturaSup=new Armatura();
pGrid.BeforeFondazioneChanged+=MyCustomEventHandler;
ExpandedProp=new List<PropertyItem>();
this.DataContext = pGrid;
}
private void MyCustomEventHandler(object sender, EventArgs e)
{
foreach (PropertyItem prop in _propertyGrid.Properties)
{
if (prop.IsExpanded==true)
{
ExpandedProp.Add(prop);
}
}
}
private void _propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e)
{
foreach (PropertyItem prop in ExpandedProp)
{
_propertyGrid.ExpandProperty(prop.PropertyName.ToString());
}
// _propertyGrid.ExpandAllProperties();
ExpandedProp.Clear();
}
public class PropGrid
{
public event EventHandler BeforeFondazioneChanged;
private bool mFondazione;
[Category("Interazione terreno")]
[RefreshProperties(RefreshProperties.All)]
[ReadOnly(false)]
public bool Fondazione
{
get { return mFondazione; }
set
{
OnBeforeFondazioneChanged();
mFondazione = value;
PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())["k"];
ReadOnlyAttribute attribute = (ReadOnlyAttribute)descriptor.Attributes[typeof(ReadOnlyAttribute)];
var fieldToChange = attribute.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault(a => a.Name.Contains("readonly", StringComparison.OrdinalIgnoreCase));
fieldToChange.SetValue(attribute, mFondazione ==false);
}
}
....
}
from wpftoolkit.
EDIT: I find that works if instead of
_propertyGrid.ExpandProperty(prop.PropertyName)
I use
_propertyGrid.ExpandProperty(prop.DispalyName)
but this raise a Binding failure: IsMiscCategoryLabelHidden
from wpftoolkit.
Hi,
This binding failure is related to the RefreshProperties attribute.
While refreshing, a MultiDataTrigger is validating the grouping and checking for a condition on IsMiscCategoryLabelHidden of a parent PropertyGrid. But the refresh re-creates the groups, and the MultiDataTrigger becomes useless in this situation. Just don`t bother about this warning.
Thanks
from wpftoolkit.
Related Issues (20)
- [Suggest] TimeSpanUpDown With Hours >= 24 HOT 3
- Publishing Project ZoomBox in Visualstudio does not work HOT 5
- PropertyGrid styling issues HOT 3
- Single file publishment with .NET6/7 crashes HOT 1
- About BusyIndicator HOT 1
- With DateTimePicker Can't Access PART_TextBox HOT 2
- CheckListBox does not allow vertical item layout with horizontal overflow HOT 1
- Validation is only displayed on the first WizardPage HOT 1
- After update to from 4.4.0 to 4.5.0 <Window.InputBindings> stop working. HOT 3
- PropertyGrid incorrect editor for IList of T, T is primitive type? HOT 1
- TimeSpanUpDown ShowDays and ShowSeconds bug inside ListView.ItemTemplate HOT 3
- RefreshProperties.All not working as I want HOT 1
- Hide area with Image, header and buttons HOT 3
- extended.wpf.toolkit is missing NuGet package README file
- Propertygrid user input data validation issue HOT 1
- CornerRadius with IntegerUpDown HOT 1
- DateTimePicker - wrong values in time picker dropdown part HOT 2
- The tag 'TimePicker' does not exist in XML namespace 'http://schemas.xceed.com/wpf/xaml/toolkit' in my WPF application
- Inconsistencies in the nuget packages HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wpftoolkit.