wpf propertyGrid
Asked Answered
C

4

5

I need a PropertyGrid for my WPF application. After lots of searches I have found this.

I have added the assembly (exe file) when I add the PropertyGrid to my form and I run it I can't see it in the form.

XAML code :

<Window x:Class="propertyGridTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpg="clr-namespace:Deepforest.WPF.Controls;assembly=WPGDemo"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Button x:Name="btn" Click="btn_Click" Height="35.5" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="55"></Button>
        <wpg:PropertyGrid x:Name="property" Width="100" Height="100"> </wpg:PropertyGrid>
    </Grid>
</Window>

code behind :

private void btn_Click(object sender, RoutedEventArgs e)
        {
            property.Instance = btn;
        }

please help me to find out why it's not visible

Consensual answered 2/11, 2009 at 12:40 Comment(0)
H
7

This is due to a bug in the WPFPropertyGrid code.

It appears from his ThemeInfoAttribute that the author of that code intended to use a generic theme, but he mistakenly put his resources in the file "Themes/default.xaml" instead of "Themes/generic.xaml". Because of this the resources were not automatically loaded. He worked around the bug by loading the resources manually from his App.xaml.

When you referenced his .exe from yours, his App.xaml wasn't loaded so his workaround wasn't activated.

The best solution is to correct the filename in the original code to "Themes/generic.xaml". If that is not possible, the second-best solution is to manually load the resources from your App.xaml:

  <Application.Resources>

    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/WPGDemo;Component/Themes/Default.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  </Application.Resources>

Or if you prefer, you can put this in a tag in your window.

Note that the above XAML assumes other resources will be used so a merge will be necessary. If not, you can skip the steps of creating a seperate dictionary and merging, and instead just set the WPGDemo dictionary as your App or Window dictionary.

Have a great day!

Handcuff answered 2/11, 2009 at 15:54 Comment(0)
Z
17

I know this is an old post, but there is a new PropertyGrid on the block and it is the most functional and feature rich one out there. Oh and it's FREE!

http://wpftoolkit.codeplex.com/

enter image description here

Zalucki answered 25/10, 2011 at 18:30 Comment(1)
This archive has migrated to github.com/xceedsoftware/wpftoolkit and is no longer free (they require a commercial license).Erzurum
H
7

This is due to a bug in the WPFPropertyGrid code.

It appears from his ThemeInfoAttribute that the author of that code intended to use a generic theme, but he mistakenly put his resources in the file "Themes/default.xaml" instead of "Themes/generic.xaml". Because of this the resources were not automatically loaded. He worked around the bug by loading the resources manually from his App.xaml.

When you referenced his .exe from yours, his App.xaml wasn't loaded so his workaround wasn't activated.

The best solution is to correct the filename in the original code to "Themes/generic.xaml". If that is not possible, the second-best solution is to manually load the resources from your App.xaml:

  <Application.Resources>

    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/WPGDemo;Component/Themes/Default.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  </Application.Resources>

Or if you prefer, you can put this in a tag in your window.

Note that the above XAML assumes other resources will be used so a merge will be necessary. If not, you can skip the steps of creating a seperate dictionary and merging, and instead just set the WPGDemo dictionary as your App or Window dictionary.

Have a great day!

Handcuff answered 2/11, 2009 at 15:54 Comment(0)
E
2

For whoever is interested, I've started a simple - but I hope useful - free and open source PropertyGrid project for WPF.

The source is available here: https://github.com/SoftFluent/SoftFluent.Windows and there is also a nuget package here: https://www.nuget.org/packages/SoftFluent.Windows.

It has no dependencies, but requires .NET 4 as it uses WPF's .NET 4 DataGrid class.

Excurvate answered 22/10, 2015 at 12:6 Comment(0)
D
-3

Did you read the documentation at the download page?

WPF Property Grid Download Page

It seems like you have to reference the property you want edited, like this for example:

<wpg:PropertyGrid Width="550" Height="550" Instance="{Binding ElementName=button}" />
<Button x:Name="button" Content="Click" />
Diagnostics answered 2/11, 2009 at 13:19 Comment(1)
yes my friend I have read it, but it didn't help . the problem is that when I put the control in my form It seems that the control is not visible ! thank youConsensual

© 2022 - 2024 — McMap. All rights reserved.