This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I got an error "Can not create instance of PropertyGrid defined in assembly 'Mindscape.WpfPropertyGrid. " when I test the propertygrid dll with code below: XAML: < Window x:Class="WPFPropertyGrid.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:Mindscape.WpfPropertyGrid;assembly=Mindscape.WpfPropertyGrid" Title="Window1" Height="800" Width="800"> <StackPanel Orientation="Vertical"> <TreeView x:Name="treeview" Height="200"/><my:PropertyGrid HorizontalAlignment="Stretch" VerticalAlignment="Top" Name="propertyGrid1" /> </StackPanel></Window>Code-behind: using Mindscape.WpfPropertyGrid;namespace WPFPropertyGrid{ /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window{ public Window1(){ InitializeComponent(); propertyGrid1.SelectedObject = treeview; } } }
Please advice. Jon |
|
|
Hi Jon, The most likely cause of this is that Visual Studio has failed to create a .licx licence file for you. Check in the Properties folder of the project. Usually the designer creates the .licx when you use a PropertyGrid control in the visual designer or XAML editor, but sometimes it fails to do so. Try dragging a PropertyGrid from the toolbox into the visual designer (and then deleting it again), or just copy a .licx file from one of the samples. Failing that, the next step is to drill into the InnerException of the error. You may need to drill down a couple of layers (WPF often wraps the real error in a TargetInvocationException) to get to the underlying cause. If you can post the details of the inner exception then we should be able to give you some more specific advice. Ivan |
|
|
Ivan, It is the license issue. Below is the error message from innerexception: {"An instance of type 'Mindscape.WpfPropertyGrid.PropertyGrid' was being created, and a valid license could not be granted for the type 'Mindscape.WpfPropertyGrid.PropertyGrid'. Please, contact the manufacturer of the component for more information."} Copy the *.licx file from the sample project could not resolve this issue. WPF toolbox does not have propertygrid control for .Net 3.0. Can you walk me through in steps? Thanks, Jon |
|
|
Hi Jon, Here are two possible approaches. 1. Reuse .licx file from sample project 1. Copy the .licx file from one of the samples into the Properties subfolder of your test project directory. 2. In Visual Studio Solution Explorer, click the Show All Files button. 3. Right-click the .licx file and choose Include in Project. 4. Right-click the .licx file and choose Properties. In the Properties window, set the Build Action to Embedded Resource. (This may be why it's not working for you at the moment.) 2. Use the toolbox and visual designer (VS2008) 1. Right-click an empty part of the the toolbox and choose Choose Items. 2. When the dialog appears, go to the WPF Components tab. 3. Browse to the WPF Property Grid assembly and choose Open. 4. Ensure that PropertyGrid appears in the component list and is checked. Choose OK. The PropertyGrid icon appears in the toolbox. 5. Open your form in the visual designer and drag the PropertyGrid icon onto it. This (usually) causes Visual Studio to realise that you're using the component and to create the .licx file. Hope this helps! |
|
|
Hi Jon, Good to hear that's solved it. You also asked about hiding properties. This can be done by adding the Browsable(false) attribute to the properties you want to hide, or by using a filter. See Help Topics > Sorting, Filtering and Grouping in the help file for an example of the latter. Ivan |
|