Home Forums WPF controls Xceed DataGrid for WPF master-detail: hide ‘collapse/expand’ button + no child rows

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26594 |

    Hi,

    has anybody faced with next issue:

    wpf datagrid is used in master-detail scenario,
    we need to hide ‘collapse/expand’ button when no child rows found..

    any help is appreciated

    thanks in advance,
    my best regards
    Volodymyr Fedyk

    Imported from legacy forums. Posted by Dorin (had 10995 views)

    Xceed Support
    Member
    Post count: 5658

    Detail relations are evaluated dynamically and the information to determine if a detail is empty is not available before the user clicks the button.

    If you are able to determine this information before hands in your object model, then you could modify the DataRow’s ControlTemplate and place an appropriate trigger on the ToggleButton visibility.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3589 views)

    User (Old forums)
    Member
    Post count: 23064

    Any chance you could provide an example of this Marcus?

    Imported from legacy forums. Posted by Steve (had 1278 views)

    Xceed Support
    Member
    Post count: 5658

    The Master/Detail example demonstrates how to hide/show empty detail configurations. Version 3.0 (due out today) also offers a Visible property on the DetailConfiguration class.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 491 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello,

    I don’t believe either of these solutions actually addresses the problem.  The example shows how to prevent the empty detail view from being shown, but does nothing to disable the collapse/expand toggle.  Likewise for the Visible attribute on the DetailConfiguration.   If not every row has detail info, it is confusing to the user if they click to expand and nothing happens.  I know there is a visual cue when the glyph changes, but this is subtle, and not nearly as useful and knowing beforehand that there is no additional information to expand.

    If Xceed’s WPF grid doesn’t currently support this, can you give us some additional information on the structure of the master/detail grid?  The control is of type ToggleButton?  What is it’s container heirarchy look like?  Is it part of DataRow directly, or is there a column for it?  Is there any accessor or means for us to apply a template or trigger to it?

    Thanks,

    –Matusz

     

    Imported from legacy forums. Posted by Matusz (had 4146 views)

    Xceed Support
    Member
    Post count: 5658

    You will need to change the ControlTemplate of DataRows. An example of a modified template can be found here:http://xceed.com/CS/files/folders/jenny/entry18669.aspx

    Imported from legacy forums. Posted by Jenny [Xceed] (had 2877 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the reply, but I’m having difficulty getting the template you posted to work.  I’m getting an error that the DataGridContext isn’t accessible, and we noticed using reflector that the property is internal.  We ignored this warning, but whenever it tried to display the datagrid we were getting an object reference not set exception, with xaml and baml related calls in the stack.

    Do you have an example project or anything that uses this template?

     

     

     

    Imported from legacy forums. Posted by Matusz (had 856 views)

    Xceed Support
    Member
    Post count: 5658

    What version of the grid are you using?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 430 views)

    User (Old forums)
    Member
    Post count: 23064

    We’re currently running v3.1.9117.10090.

    Imported from legacy forums. Posted by Matusz (had 783 views)

    Xceed Support
    Member
    Post count: 5658

    DataGridContext is a public attached property defined on the DataGridControl class and should be available in the version you are using. Can you post the error/warning you are getting?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 779 views)

    User (Old forums)
    Member
    Post count: 23064

    The warning comes from ReSharper, and simply states “DataGridContext is not accessible.”  Because this differed from the documentation we inspected the assembly using Reflector and it also identified the property as internal.

    I’ve commented out the trigger using the DependentOn Property before running to rule out the possibility that my implementation of that section is the cause.  I also tried to place a very simple style in DataGridControl.Resources that used a reference to DataGridContext, using the same binding as in the example template.  In that case, I get the innermost exception below, the NullReferenceException.

    The full exception detail is as follows:

     System.Reflection.TargetInvocationException was unhandled
      Message=”Exception has been thrown by the target of an invocation.”
      Source=”mscorlib”
      StackTrace:
           at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           at System.Delegate.DynamicInvokeImpl(Object[] args)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
           at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           at System.Windows.Application.RunInternal(Window window)
           at NewWorld.Aegis.Dispatch.Desktop.App.Main() in C:\Code\TFS\CAD\Dispatch\DEV\Client\AegisDispatch\obj\Debug\App.g.cs:line 50
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: Microsoft.Practices.Unity.ResolutionFailedException
           Message=”Resolution of the dependency failed, type = \”NewWorld.Aegis.Dispatch.Core.UnitPersonnel.IUnitPersonnelPresentationModel\”, name = \”\”. Exception message is: The current build operation (build key Build Key[NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel, null]) failed: The parameter view could not be resolved when attempting to call constructor NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel(NewWorld.Aegis.Dispatch.Core.UnitPersonnel.IUnitPersonnelView view, NewWorld.Aegis.Dispatch.Interface.IDispatchService dispatchService, NewWorld.Aegis.Dispatch.Interface.CommandProcessing.ICommandProcessorService commandProcessorService). (Strategy type BuildPlanStrategy, index 3)”
           Source=”Microsoft.Practices.Unity”
           TypeRequested=”IUnitPersonnelPresentationModel”
           StackTrace:
                at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
                at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String name)
                at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name)
                at Microsoft.Practices.Unity.UnityContainerBase.Resolve(Type t)
                at Microsoft.Practices.Unity.UnityContainerBase.Resolve[T]()
                at NewWorld.Aegis.Dispatch.Core.Controller.CoreController.DisplayUnitPersonnel(Unit unit) in C:\Code\TFS\CAD\Dispatch\DEV\Client\Modules\Core\Controller\CoreController.cs:line 342
           InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
                Message=”The current build operation (build key Build Key[NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel, null]) failed: The parameter view could not be resolved when attempting to call constructor NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel(NewWorld.Aegis.Dispatch.Core.UnitPersonnel.IUnitPersonnelView view, NewWorld.Aegis.Dispatch.Interface.IDispatchService dispatchService, NewWorld.Aegis.Dispatch.Interface.CommandProcessing.ICommandProcessorService commandProcessorService). (Strategy type BuildPlanStrategy, index 3)”
                Source=”Microsoft.Practices.ObjectBuilder2″
                BuildKey=”Build Key[NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel, null]”
                ExecutingStrategyIndex=3
                ExecutingStrategyTypeName=”BuildPlanStrategy”
                StackTrace:
                     at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                     at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
                     at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
                InnerException: System.InvalidOperationException
                     Message=”The parameter view could not be resolved when attempting to call constructor NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel(NewWorld.Aegis.Dispatch.Core.UnitPersonnel.IUnitPersonnelView view, NewWorld.Aegis.Dispatch.Interface.IDispatchService dispatchService, NewWorld.Aegis.Dispatch.Interface.CommandProcessing.ICommandProcessorService commandProcessorService).”
                     Source=”Microsoft.Practices.ObjectBuilder2″
                     StackTrace:
                          at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForResolutionFailed(Exception inner, String parameterName, String constructorSignature, IBuilderContext context)
                          at BuildUp_NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel(IBuilderContext )
                          at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
                          at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                          at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                     InnerException: Microsoft.Practices.ObjectBuilder2.BuildFailedException
                          Message=”The current build operation (build key Build Key[NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelView, null]) failed: Object reference not set to an instance of an object. (Strategy type BuildPlanStrategy, index 3)”
                          Source=”Microsoft.Practices.ObjectBuilder2″
                          BuildKey=”Build Key[NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelView, null]”
                          ExecutingStrategyIndex=3
                          ExecutingStrategyTypeName=”BuildPlanStrategy”
                          StackTrace:
                               at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                               at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
                               at BuildUp_NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelPresentationModel(IBuilderContext )
                          InnerException: System.NullReferenceException
                               Message=”Object reference not set to an instance of an object.”
                               Source=”PresentationFramework”
                               StackTrace:
                                    at System.Windows.Markup.XmlnsCache.GetClrnsToAssemblyNameMappingList(Assembly[] asmList, String xmlnsRequested)
                                    at System.Windows.Markup.XmlnsCache.GetMappingArray(String xmlns)
                                    at System.Windows.Markup.XamlTypeMapper.GetClrNamespacePairFromCache(String namespaceUri)
                                    at System.Windows.Markup.XamlTypeMapper.GetNamespaceMapEntries(String xmlNamespace)
                                    at System.Windows.Markup.XamlTypeMapper.CreateTypeAndSerializer(String xmlNamespace, String localName)
                                    at System.Windows.Markup.XamlTypeMapper.GetTypeOnly(String xmlNamespace, String localName)
                                    at System.Windows.PropertyPath.GetTypeFromName(String name, Object context)
                                    at System.Windows.PropertyPath.ResolvePropertyName(String name, Object item, Type ownerType, Object context, Boolean throwOnError)
                                    at System.Windows.PropertyPath.ResolvePathParts(ITypeDescriptorContext typeDescriptorContext)
                                    at System.Windows.PropertyPath..ctor(String path, ITypeDescriptorContext typeDescriptorContext)
                                    at System.Windows.PropertyPathConverter.ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, Object source)
                                    at System.Windows.Markup.XamlTypeMapper.ParseProperty(Object targetObject, Type propType, String propName, Object dpOrPiOrFi, ITypeDescriptorContext typeContext, ParserContext parserContext, String value, Int16 converterTypeId)
                                    at System.Windows.Markup.BamlRecordReader.ParseProperty(Object element, Type propertyType, String propertyName, Object dpOrPi, String attribValue, Int16 converterTypeId)
                                    at System.Windows.Markup.BamlRecordReader.ReadPropertyRecordBase(String attribValue, Int16 attributeId, Int16 converterTypeId)
                                    at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
                                    at System.Windows.Markup.StyleBamlRecordReader.ReadRecord(BamlRecord bamlRecord)
                                    at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
                                    at System.Windows.Markup.StyleTreeBuilderBamlTranslator.ParseFragment()
                                    at System.Windows.Markup.TreeBuilder.Parse()
                                    at System.Windows.Markup.XamlStyleSerializer.ConvertBamlToObject(BamlRecordReader reader, BamlRecord bamlRecord, ParserContext context)
                                    at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
                                    at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
                                    at System.Windows.Markup.BamlRecordReader.ReadElement(Int64 startPosition, XamlObjectIds contextXamlObjectIds, Object dictionaryKey)
                                    at System.Windows.ResourceDictionary.CreateObject(Int32 valuePosition, Object key)
                                    at System.Windows.ResourceDictionary.RealizeDeferContent(Object key, Object& value, Boolean& canCache)
                                    at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
                                    at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
                                    at System.Windows.FrameworkElement.FindResourceOnSelf(Object resourceKey, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
                                    at System.Windows.Markup.BamlRecordReader.FindResourceInParserStack(Object resourceNameObject, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
                                    at System.Windows.Markup.BamlRecordReader.FindResourceInParentChain(Object resourceNameObject, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
                                    at System.Windows.StaticResourceExtension.ProvideValueInternal(IBamlReader bamlReader, Object targetObject, Object targetProperty, Boolean allowDeferredReference)
                                    at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
                                    at System.Windows.Markup.BamlRecordReader.ProvideValueFromMarkupExtension(MarkupExtension markupExtension, Object obj, Object member)
                                    at System.Windows.Markup.BamlRecordReader.BaseReadOptimizedMarkupExtension(Object element, Int16 attributeId, PropertyDefinition propertyDefinition, Object value)
                                    at System.Windows.Markup.BamlRecordReader.ReadPropertyWithExtensionRecord(BamlPropertyWithExtensionRecord bamlPropertyRecord)
                                    at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
                                    at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
                                    at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
                                    at System.Windows.Markup.TreeBuilder.Parse()
                                    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
                                    at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
                                    at NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelView.InitializeComponent() in c:\Code\TFS\CAD\Dispatch\DEV\Client\Modules\Core\UnitPersonnel\UnitPersonnelView.xaml:line 1
                                    at NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelView..ctor() in C:\Code\TFS\CAD\Dispatch\DEV\Client\Modules\Core\UnitPersonnel\UnitPersonnelView.xaml.cs:line 29
                                    at BuildUp_NewWorld.Aegis.Dispatch.Core.UnitPersonnel.UnitPersonnelView(IBuilderContext )
                                    at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
                                    at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
                                    at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
                               InnerException:

     

    Imported from legacy forums. Posted by Matusz (had 1221 views)

    Xceed Support
    Member
    Post count: 5658

    It is an attached property, which means that you should look for GetDataGridContext and SetDataGridContext methods rather than a DataGridContext property when using reflector.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 631 views)

    User (Old forums)
    Member
    Post count: 23064

    Ah, that does explain the discrepancy.  Unfortunately it doesn’t make the null reference any less puzzling.  Any ideas as to why that might be occurring?  I’ve tried other examples from the documentation with similar results.  Anything we do involving the DataGridControl.DataContext in xaml results in a NullReferenceException.

    Imported from legacy forums. Posted by Matusz (had 979 views)

    Xceed Support
    Member
    Post count: 5658

    Would you be able to test the “Providing a Default Detail Configuration” that is available in the documentation? It uses the DataGridContext in a “simpler” manner.

    As for the NullReferenceException, is there an inner exception?  

    Imported from legacy forums. Posted by Jenny [Xceed] (had 698 views)

    User (Old forums)
    Member
    Post count: 23064

    That was the example from the documentation I referred to in my previous post.  I get the same result.

    There is no inner exception, and the stack trace isn’t particularly useful.  It’s the same as the bottom section of the exception detail above.  That last “Inner Exception:” isn’t being cut off, that’s just how Visual Studio formats it when the value is null.

    Imported from legacy forums. Posted by Matusz (had 1067 views)

Viewing 15 posts - 1 through 15 (of 24 total)
  • You must be logged in to reply to this topic.