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
|
Not being a C# guy by nature, I can't seem to get the dialogesque example to work...I get this error when i compile it... Error 7 'Templating.DialogesqueTemplateSelector.LeftLabelled.get' must declare a body because it is not marked abstract or extern C:\Documents and Settings\eudvm06\My Documents\Visual Studio 2005\Projects\Templating\Templating\Dialogesque.xaml.cs 40 40 Templating One other question I have is how do I get rid of the little "close" (or delete) glyphs in each property in the grid. I don't want users closing the individual properties...
|
|
|
We inadvertently left some C# 3.0 syntax in the v1.0 samples, and C# 3.0 is part of VS2008, not VS2005. If you pull down a current nightly build (trial version at http://www.mindscape.co.nz/Products/WpfPropertyGrid/nightlybuilds.aspx, retail version from the store), the samples should all run on VS2005 (in fact we added VS2005-format project and solution files to save you having to create these yourself). Alternatively, if you would prefer to just fix things up in situ, you need to change: public DataTemplate LeftLabelled { get; set; } to: private DataTemplate _leftLabelled; public DataTemplate LeftLabelled and similarly for RightLabelled. Sorry about that! |
|
|
Ok, so that compiles Ok, and now I have another issue... On both the Poppy and Dialogesque examples, I replaced the datacontext with an Itemsource, which is an observable dictionary of type string, object... When the grid displays, instead of seeing property names and objects, I see a type of Mindscape.WPFPropertyGrid.PropertyGridRow... What Do i need to change in the xaml to see the itemsource properties? |
|
|
Hmm, it seems to be working okay for me, but I may be doing something different from you. Here's the code I'm using to try to reproduce it (in the Dialogesque constructor): // old line commented out // new code trying to reproduce issue With this I see the two expected entries in the templated grid. Could you post your code and I will have a look? Thanks! |
|
|
I just realised I forgot to answer your question about removing the "delete" glyphs. Sorry! Set AllowModifyCollections="False" in the property grid declaration and they won't bother you again. |
|
|
Thanks for all the help Ivan, I'm just about ready to purchase, but I need to resolve this one issue... I've posted code that loads an observable dictionary of string, object, and loads in two string properties, then loads another observable dictionary of "detail" items. When I run this in my "poppy" example, i can see all the properties, but i cannot expand the details node - The details show up but just say "2 items" When I run this same code in the dialogesque example, I don't see the properties, just "mindscape.wpfpropertygrid.propertygridrow" displayed. I'll post the vb that loads both dictionaries, and the xaml for the dialogesque example... Dim prefs As New ObservableDictionary(Of String, Object)prefs.Add( "Name", "Mitch")prefs.Add("Some", "Stuff") Dim subprefs As New ObservableDictionary(Of String, Object)subprefs.Add("Wife", "Tracy")subprefs.Add( "Dog", "Marley")prefs.Add("Details", subprefs)TemplatedGrid.ItemsSource = prefs Dim grouper As New PropertyGroupDescription("Node", New ComponentGroupConverter())TemplatedGrid.BindingView.DefaultView.GroupDescriptions.Add(grouper)
...and the xaml is...
< Window x:Class="Dialogesque" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ms="http://namespaces.mindscape.co.nz/wpf" xmlns:local="clr-namespace:LuthiersLog" WindowStartupLocation="CenterScreen"Title="Dialogesque" Height="400" Width="750" MinHeight="400" MinWidth="750">< Window.Resources><DataTemplate x:Key="RightLabelled">< StackPanel Orientation="Horizontal" Margin="4,0,0,0"><ContentPresenter ContentTemplateSelector="{Binding EditorSelector, RelativeSource={RelativeSource AncestorType={x:Type ms:PropertyGrid}}}" Margin="2" />< TextBlock Text="{Binding Node.HumanName}" Margin="10,2,2,2" /></StackPanel></ DataTemplate><DataTemplate x:Key="LeftLabelled">< Grid><Grid.ColumnDefinitions>< ColumnDefinition SharedSizeGroup="Caption" /><ColumnDefinition /></ Grid.ColumnDefinitions><StackPanel Orientation="Horizontal" Grid.Column="0" VerticalAlignment="Center">< TextBlock Text="{Binding Node.HumanName}" /><TextBlock Text=": " /></ StackPanel><ContentPresenter ContentTemplateSelector="{Binding EditorSelector, RelativeSource={RelativeSource AncestorType={x:Type ms:PropertyGrid}}}" Grid.Column="1" /></ Grid></DataTemplate>< local:DialogesqueTemplateSelector x:Key="DialogStyleSelector" RightLabelled="{StaticResource RightLabelled}"LeftLabelled="{StaticResource LeftLabelled}" />< Style x:Key="Dialogesque" TargetType="{x:Type ms:PropertyGrid}"><Setter Property="Template">< Setter.Value><ControlTemplate TargetType="{x:Type ms:PropertyGrid}">< ItemsControl ItemsSource="{TemplateBinding BindingView}" ItemTemplateSelector="{StaticResource DialogStyleSelector}"><ItemsControl.GroupStyle>< GroupStyle><GroupStyle.ContainerStyle>< Style TargetType="{x:Type GroupItem}"><Setter Property="Grid.IsSharedSizeScope" Value="True" />< Setter Property="Template"><Setter.Value>< ControlTemplate TargetType="{x:Type GroupItem}"><GroupBox Header="{Binding Name}" Margin="8,4,8,4" Padding="4">< ItemsPresenter /></GroupBox></ ControlTemplate></Setter.Value></ Setter></Style></ GroupStyle.ContainerStyle></GroupStyle></ ItemsControl.GroupStyle></ItemsControl></ ControlTemplate></Setter.Value></ Setter></Style></ Window.Resources><Grid>< Grid.ColumnDefinitions><ColumnDefinition Width="5*" />< ColumnDefinition Width="40" /><ColumnDefinition Width="4*" /></ Grid.ColumnDefinitions><DockPanel>< StackPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Orientation="Horizontal"><Button Click="LoadTheGrid">Load Grid</Button>< UniformGrid Columns="2"><UniformGrid.Resources>< Style x:Key="{x:Type Button}" TargetType="{x:Type Button}"><Setter Property="Padding" Value="2" />< Setter Property="Margin" Value="4" /></Style></ UniformGrid.Resources><Button Click="CloseWindow">OK</Button>< Button Click="CloseWindow">Cancel</Button></UniformGrid></ StackPanel><ms:PropertyGrid SelectedObject="{Binding}" Style="{StaticResource Dialogesque}" Name="TemplatedGrid">< ms:PropertyGrid.Editors><ms:PropertyEditor PropertyName="IgnoreWordsInUppercase" EditorTemplate="{StaticResource {x:Static ms:PropertyGrid.CheckBoxEditorKey}}" />< ms:PropertyEditor PropertyName="IgnoreWordsThatContainNumbers" EditorTemplate="{StaticResource {x:Static ms:PropertyGrid.CheckBoxEditorKey}}" /><ms:PropertyEditor PropertyName="IgnoreInternetAndFileAddresses" EditorTemplate="{StaticResource {x:Static ms:PropertyGrid.CheckBoxEditorKey}}" />< ms:PropertyEditor PropertyName="EnforceAccentedUppercase" EditorTemplate="{StaticResource {x:Static ms:PropertyGrid.CheckBoxEditorKey}}" /></ms:PropertyGrid.Editors>< ms:PropertyGrid.BuiltInEditorStyles><ms:BuiltInEditorStyle EditorKey="{x:Static ms:PropertyGrid.CheckBoxEditorKey}">< Style TargetType="{x:Type CheckBox}"><Setter Property="Template">< Setter.Value><ControlTemplate TargetType="{x:Type CheckBox}">< CheckBox IsChecked="{Binding Value, Mode=TwoWay}" /></ControlTemplate></ Setter.Value></Setter></ Style></ms:BuiltInEditorStyle>< ms:BuiltInEditorStyle EditorKey="{x:Static ms:PropertyGrid.SimpleTextEditorKey}"><Style TargetType="{x:Type ms:TextBox}">< Setter Property="Template"><Setter.Value>< ControlTemplate TargetType="{x:Type ms:TextBox}"><ms:TextBox Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="6,1,10,1" /></ ControlTemplate></Setter.Value></ Setter></Style></ ms:BuiltInEditorStyle><ms:BuiltInEditorStyle EditorKey="{x:Static ms:PropertyGrid.ListSelectEditorKey}">< Style TargetType="{x:Type ComboBox}"><Setter Property="Template">< Setter.Value><ControlTemplate TargetType="{x:Type ComboBox}">< ComboBox ItemsSource="{TemplateBinding ItemsSource}" Text="{TemplateBinding Text}" SelectedValue="{Binding Value, Mode=TwoWay}" Margin="6,1,10,1" /></ControlTemplate></ Setter.Value></Setter></ Style></ms:BuiltInEditorStyle></ ms:PropertyGrid.BuiltInEditorStyles></ms:PropertyGrid></ DockPanel><Border Padding="10" Grid.Column="2">< ms:PropertyGrid SelectedObject="{Binding}" /></Border></ Grid></ Window> |
|
|
You need to add two things to Poppy and Dialogesque to support expandable nodes: first, the expand UI in the "property name" template, and second, the hierarchy in the PropertyGrid control template. I'll discuss these in the Poppy context because it's easier (Dialogesque does some rather more radical surgery and I'll talk about that later). First, let's add the expander UI back in. Go into Poppy.xaml and find the DataTemplate with a key of "PropertyNameCellTemplate." At the moment this is just a Border with a TextBlock. Wrap that TextBlock in a StackPanel with Orientation="Horizontal", and add a ToggleButton as follows: <ToggleButton Name="Expander" (I'm ignoring multiple levels of hierarchy for now. If you need that, add Margin="{Binding Level,Converter={StaticResource LevelToIndentConverter},RelativeSource={RelativeSource AncestorType={x:Type local:TreeListViewItem}}}". Use the LevelToIndentConverter class from the grid assembly.) If you try this, you'll find every row now has an expand button. We want to hide it for rows that have no children, so add a trigger to the DataTemplate: <DataTemplate.Triggers> This should now look correct, but if you try toggling the button, you'll find that nothing appears. This is because the instructions for how to find the child nodes are part of the property grid control template. Poppy replaced that control template and didn't include the instructions. To add them back, add the following resource: <HierarchicalDataTemplate x:Key="PropertyGridHierarchy" ItemsSource="{Binding Children}" /> This says that the ItemsSource for the "next level down" is the Children collection of the current level. Hook this up to the grid template as follows: <ControlTemplate TargetType="{x:Type ms:PropertyGrid}"> (the bold bit is new, the rest is just to help you find where I mean). This restores expandable behaviour to Poppy. Why are things more difficult in Dialogesque? We can set up the UI in the same way, but when we come to hook up the hierarchy, we find that Dialogesque uses an ItemsControl rather than a TreeListView as its control template. So we need to manually provide for showing and hiding the children. The way to do this is to add an ItemsControl below the existing body of the DataTemplate (you probably only need to do this for LeftLabelled as the UI would look a bit odd if you had something that was expandable and right-labelled), and set its Visibility to "{Binding IsChecked, ElementName=Expander, Converter={StaticResource bvc}}", where bvc is a BooleanToVisibilityConverter. (You will also need to remove the IsChecked binding from Expander, as we don't have a TreeListViewItem for it to bind to.) You will probably need to do a bit of experimenting with the ItemTemplate/ItemTemplateSelector for this ItemsControl to get things lined up and looking nice, but hopefully this gives you enough pointers to get under way. I'm afraid I am still not seeing your issue where it displays "Mindscape.WpfPropertyGrid.PropertyGridRow" in Dialogesque instead of the correct content, even using your XAML and code (admittedly translated to C#, but that shouldn't make a difference). Would it be possible for you to try this again with a current nightly build? If it still fails with the current nightly, could you zip up your entire test project and post it as an attachment (via the options tab)? (Or mail it via the contact form if you don't want other people to see it.) |
|
|
Thanks Ivan - I'll get the nightly and have a go at the dialogesque with the pointers you left me here. I do have to say this is one heck of product. |
|