private void cmdViewSubObject_Click(object sender, RoutedEventArgs e) { PropertyGridItem propItem = PropertyGrid.SelectedItem as PropertyGridItem; if (propItem == null) { return; } IPropertyInspectable item = propItem.ValueObj as IPropertyInspectable; if (item == null) { return; } // Todo: Event für Unterobject implementieren!! RaiseEvent(new PropInspRoutedEventArgs(InspectSubObjectEvent, item)); //RaiseEvent(new RoutedEventArgs(InspectSubObjectEvent)); //PropertyInspect pi = new PropertyInspect(item); //pi.Show(); }
private void ColorPicker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e) { try { PropertyGridItem item = PropertyGrid.SelectedItem as PropertyGridItem; if (item != null) { if (sender is ColorPicker) { var b = sender as ColorPicker; item.SetValue(b.SelectedColor); // Debug.WriteLine("=> Selected = " + b.SelectedValue + ":" + b.SelectedValue.GetType().Name); // Debug.WriteLine("=> Sett = " + item.ValueAsKey + ":" + item.ValueObj.GetType().Name); UpdateProperty(item); //PropertyGrid.Items.Refresh(); } } } catch (Exception ex) { } }
private void UpdateProperty(PropertyGridItem propItem) { var typ = ObjectToInspect.GetType(); var prop = typ.GetProperty(propItem.Name); prop.SetValue(ObjectToInspect, propItem.ValueObj); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { PropertyGridItem propgs = (item as PropertyGridItem); object value = null; if (propgs != null) { value = propgs.ValueObj; } if (value != null) { if (value is String) { if (propgs.Name.Equals("Name") || propgs.Name.Equals("TypeName")) { return(ObjectStaticTextTemplate); } else { return(ObjectTextTemplate); } } } if (value is Boolean) { return(ObjectBooleanTemplate); } else if (value is double) { return(ObjectDoubleTemplate); } else if (value is int) { return(ObjectIntTemplate); } else if (value is Key) { return(ObjectKeyEnumTemplate); } else if (value is Enum) { return(ObjectEnumTemplate); } else if (value is Vector) { return(ObjectVectorTemplate); } else if (value is Color) { return(ObjectColorTemplate); } else if (value is Rect) { return(ObjectRectTemplate); } else if (value is IPropertyInspectable) { return(SubObjectTemplate); } else { return(base.SelectTemplate(item, container)); } }