Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1255
Errors when creating Style for ToggleButtonTool
posted

Following information is provided about the difficulties I am having creating styles for certain Infragistics control types (v8.1).  I am using the ToggleButtonTool as this example, but I experience similar or identical problems with other Infragistics controls.  If there is some clue you can see as to why this is happening, please let me know.  I do not see other posts here in the forum about people having these types of issues with styles and control templates, so perhaps there is something in my references or configuration that is wrong??

The ability to use Styles and Templates on these controls is required by my current project, but I have reached an impass as described below.

In Expression Blend 2.0, when I try to create a style for a ToggleButtonTool, I get the following error:

InvalidCastException:  Unable to cast object of type 'Microsoft.Expression.DesignModel.Core.DocumentPrimitiveNode' to type 'Microsoft.Expression.DesignModel.Core.DocumentCompositeNode'.

I can provide you the stack trace if necessary, but I must copy it by manually typing it here because it is not copy/paste-able from the Blend error list. :(

Because of the error I can not work with the view that defines this style in Blend.  Blend just shows the exception and will not load anything into the designer.  If I go over to VS2008 to work with the style, I get the following error at design time:

The attachable property "Converter" not found in type "TemplateBinding".

Then I get the following error at runtime (thank you VS for allowing me to copy/paste this error message):

System.Windows.Markup.XamlParseException occurred

  Message="Cannot convert string '(0)' in attribute 'Path' to object of type 'System.Windows.PropertyPath'. Index 0 is out of range of the PathParameters list, which has length 0.  Error at object 'System.Windows.Data.Binding' in markup file 'CompanyName.PS.WPF;component/pages/community development/land management/locationmapsearch/locationmappingview.xaml' Line 969 Position 23."

  Source="PresentationFramework"

  LineNumber=969

  LinePosition=23

  StackTrace:

       at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)

       at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)

       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.ReadPropertyConverterRecord(BamlPropertyWithConverterRecord bamlPropertyRecord)

       at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.OptimizedTemplateContentHelper.ReadSubtreeRecord(BamlRecord record)

       at System.Windows.Markup.OptimizedTemplateContent.ReadSharedRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.OptimizedTemplateContent.ReadRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.OptimizedTemplateContent.AddContentRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.TemplateBamlRecordReader.AddContentRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.TemplateBamlRecordReader.ReadRecord(BamlRecord bamlRecord)

       at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)

       at System.Windows.Markup.TemplateTreeBuilderBamlTranslator.ParseFragment()

       at System.Windows.Markup.TreeBuilder.Parse()

       at System.Windows.Markup.XamlTemplateSerializer.ConvertBamlToObject(BamlRecordReader reader, BamlRecord bamlRecord, ParserContext context)

       at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)

       at System.Windows.Markup.StyleBamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)

       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.DeferredResourceReference.GetValue(BaseValueSourceInternal valueSource)

       at System.Windows.DependencyPropertyChangedEventArgs.get_NewValue()

       at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)

       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)

       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)

       at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)

       at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

       at System.Windows.Markup.BamlRecordReader.SetDependencyValueCore(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)

       at System.Windows.Markup.BamlRecordReader.SetDependencyValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)

       at System.Windows.Markup.BamlRecordReader.SetPropertyValue(Object o, PropertyDefinition propertyDefinition, Object value)

       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 CompanyName.PS.WPF.LocationMappingView.InitializeComponent() in c:\WinSolution\CompanyName.PS.WPF\CompanyName.PS.WPF\Pages\Community Development\Land Management\LocationMapSearch\LocationMappingView.xaml:line 1

       at CompanyName.PS.WPF.LocationMappingView..ctor() in C:\WinSolution\CompanyName.PS.WPF\CompanyName.PS.WPF\Pages\Community Development\Land Management\LocationMapSearch\LocationMappingView.xaml.cs:line 128

  InnerException: System.InvalidOperationException

       Message="Index 0 is out of range of the PathParameters list, which has length 0."

       Source="PresentationFramework"

       StackTrace:

            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.PrepareSourceValueInfo(ITypeDescriptorContext typeDescriptorContext)

            at System.Windows.PropertyPath..ctor(String path, ITypeDescriptorContext typeDescriptorContext)

            at System.Windows.PropertyPathConverter.ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, Object source)

            at System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, String text)

            at System.Windows.Markup.XamlTypeMapper.ParseProperty(Object targetObject, Type propType, String propName, Object dpOrPiOrFi, ITypeDescriptorContext typeContext, ParserContext parserContext, String value, Int16 converterTypeId)

       InnerException:

The Style xaml is generated, however, as follows:

<Style x:Key="FloatMapToggleButtonStyle" TargetType="{x:Type igRibbon:ToggleButtonTool}">

<Setter Property="ToolTipService.ShowDuration" Value="20000"/>

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.ToolEnabledForegroundTextFillKey}"/>

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type igRibbon:ToggleButtonTool}">

<igRibbon:RibbonButtonChrome SnapsToDevicePixels="True" x:Name="chrome" IsChecked="{TemplateBinding IsChecked}" IsPressed="{TemplateBinding IsPressed}">

<Grid HorizontalAlignment="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource TemplatedParent}}" Margin="1,1,1,1" x:Name="chromeContentPanel">

<Grid.RowDefinitions>

<RowDefinition Height="*" x:Name="row0"/>

<RowDefinition Height="Auto" x:Name="row1"/>

<RowDefinition Height="Auto"/>

</Grid.RowDefinitions>

<Grid.ColumnDefinitions>

<ColumnDefinition Width="Auto"/>

<ColumnDefinition Width="Auto"/>

</Grid.ColumnDefinitions>

<igWindows:AutoDisabledImage x:Name="image" Width="16" Height="16" Source="{TemplateBinding}" igRibbon:XamRibbon.KeyTipPlacementType="SmallImage">

<igWindows:AutoDisabledImage.Visibility>

<Binding Path="(0)" RelativeSource="{RelativeSource TemplatedParent}">  <---------------------------------RUNTIME ERROR HERE

<Binding.Converter>

<BooleanToVisibilityConverter/>

</Binding.Converter>

</Binding>

</igWindows:AutoDisabledImage.Visibility>

</igWindows:AutoDisabledImage>

<ContentPresenter SnapsToDevicePixels="True" Margin="3,0,2,1" x:Name="textSmall" VerticalAlignment="Center" Grid.Column="1" Block.TextAlignment="Left" igRibbon:RibbonGroupPanel.SizingModeVersion="{TemplateBinding igRibbon:RibbonGroupPanel.SizingModeVersion}">

<ContentPresenter.Content>

<TemplateBinding>

<TemplateBinding.Converter>

<igWindows:StringWithoutMnemonicsConverter/>

</TemplateBinding.Converter>

</TemplateBinding>

</ContentPresenter.Content>

</ContentPresenter>

<igRibbon:LargeToolCaptionPresenter Visibility="Collapsed" x:Name="textLarge" Grid.Row="2">

<igRibbon:LargeToolCaptionPresenter.Text>

<TemplateBinding>

<TemplateBinding.Converter>

<igWindows:StringWithoutMnemonicsConverter/>

</TemplateBinding.Converter>

</TemplateBinding>

</igRibbon:LargeToolCaptionPresenter.Text>

</igRibbon:LargeToolCaptionPresenter>

</Grid>

</igRibbon:RibbonButtonChrome>

<ControlTemplate.Triggers>

<Trigger Property="IsChecked" Value="True">

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.TextHottrackFillKey}"/>

</Trigger>

<Trigger Property="IsMouseOver" Value="True">

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.TextHottrackFillKey}"/>

</Trigger>

<MultiTrigger>

<MultiTrigger.Conditions>

<Condition>

<Condition.Value>

<igRibbon:RibbonToolSizingMode>ImageOnly</igRibbon:RibbonToolSizingMode>

</Condition.Value>

</Condition>

<Condition>

<Condition.Value>

<System:Boolean>True</System:Boolean>

</Condition.Value>

</Condition>

</MultiTrigger.Conditions>

<Setter Property="Visibility" TargetName="textSmall" Value="Collapsed"/>

</MultiTrigger>

<MultiTrigger>

<MultiTrigger.Conditions>

<Condition>

<Condition.Value>

<igRibbon:RibbonToolSizingMode>ImageAndTextLarge</igRibbon:RibbonToolSizingMode>

</Condition.Value>

</Condition>

<Condition Property="igRibbon:XamRibbon.Location" Value="Ribbon"/>

</MultiTrigger.Conditions>

<Setter Property="Visibility" TargetName="textSmall" Value="Collapsed"/>

<Setter Property="Visibility" TargetName="textLarge" Value="Visible"/>

<Setter Property="Width" TargetName="image" Value="32"/>

<Setter Property="Height" TargetName="image" Value="32"/>

<Setter Property="Margin" TargetName="image" Value="0,0,0,2"/>

<Setter Property="Height" TargetName="row0" Value="Auto"/>

<Setter Property="Height" TargetName="row1" Value="*"/>

<Setter Property="Margin" TargetName="chromeContentPanel" Value="1,1,1,0"/>

</MultiTrigger>

<Trigger Property="igRibbon:XamRibbon.Location" Value="Ribbon">

<Setter Property="HorizontalAlignment" Value="Left"/>

</Trigger>

<Trigger Property="igRibbon:XamRibbon.Location" Value="QuickAccessToolbar">

<Setter Property="Margin" Value="0,-2,0,0"/>

<Setter Property="Padding" TargetName="chrome" Value="0,2,0,0"/>

</Trigger>

<MultiDataTrigger>

<MultiDataTrigger.Conditions>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.Location), RelativeSource={RelativeSource Self}}" Value="QuickAccessToolbar"/>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.IsGlassActive), RelativeSource={RelativeSource Self}}" Value="False"/>

</MultiDataTrigger.Conditions>

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.ToolInQATForegroundTextFillKey}"/>

</MultiDataTrigger>

<MultiDataTrigger>

<MultiDataTrigger.Conditions>

<Condition Binding="{Binding Path=Location, RelativeSource={RelativeSource Self}}" Value="QuickAccessToolbar"/>

<Condition Binding="{Binding Path=IsBelowRibbon, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type igRibbon:QuickAccessToolbar}}}" Value="False"/>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.IsGlassActive), RelativeSource={RelativeSource Self}}" Value="True"/>

<Condition Binding="{Binding Path=WindowState, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Window}}}" Value="Normal"/>

</MultiDataTrigger.Conditions>

<Setter Property="BitmapEffect" TargetName="textSmall">

<Setter.Value>

<OuterGlowBitmapEffect GlowColor="#FFFFFFFF" GlowSize="10" Noise="0" Opacity="0.6"/>

</Setter.Value>

</Setter>

<Setter Property="BitmapEffect" TargetName="textLarge">

<Setter.Value>

<OuterGlowBitmapEffect GlowColor="#FFFFFFFF" GlowSize="10" Noise="0" Opacity="0.6"/>

</Setter.Value>

</Setter>

</MultiDataTrigger>

<Trigger Property="igRibbon:XamRibbon.HideAccessKey" Value="False">

<Setter Property="RecognizesAccessKey" TargetName="textSmall" Value="True"/>

<Setter Property="Content" TargetName="textSmall" Value="{Binding Path=(0), RelativeSource={RelativeSource TemplatedParent}}"/>

</Trigger>

<Trigger Property="IsEnabled" Value="False">

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.ToolDisabledForegroundTextFillKey}"/>

</Trigger>

</ControlTemplate.Triggers>

</ControlTemplate>

</Setter.Value>

</Setter>

<Style.Triggers>

<MultiDataTrigger>

<MultiDataTrigger.Conditions>

<Condition Binding="{Binding Path=Location, RelativeSource={RelativeSource Self}}" Value="QuickAccessToolbar"/>

<Condition Binding="{Binding Path=IsBelowRibbon, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type igRibbon:QuickAccessToolbar}}}" Value="False"/>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.IsGlassActive), RelativeSource={RelativeSource Self}}" Value="True"/>

<Condition Binding="{Binding Path=WindowState, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Window}}}" Value="Normal"/>

</MultiDataTrigger.Conditions>

<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}"/>

</MultiDataTrigger>

<MultiDataTrigger>

<MultiDataTrigger.Conditions>

<Condition Binding="{Binding Path=Location, RelativeSource={RelativeSource Self}}" Value="QuickAccessToolbar"/>

<Condition Binding="{Binding Path=IsBelowRibbon, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type igRibbon:QuickAccessToolbar}}}" Value="False"/>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.IsGlassActive), RelativeSource={RelativeSource Self}}" Value="True"/>

<Condition Binding="{Binding Path=WindowState, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type Window}}}" Value="Maximized"/>

</MultiDataTrigger.Conditions>

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.VistaWindowMaximizedTextFillKey}"/>

</MultiDataTrigger>

<MultiDataTrigger>

<MultiDataTrigger.Conditions>

<Condition Binding="{Binding Path=Location, RelativeSource={RelativeSource Self}}" Value="QuickAccessToolbar"/>

<Condition Binding="{Binding Path=(igRibbon:XamRibbon.IsGlassActive), RelativeSource={RelativeSource Self}}" Value="False"/>

</MultiDataTrigger.Conditions>

<Setter Property="Foreground" Value="{DynamicResource RibbonBrushKeys.ToolInQATForegroundTextFillKey}"/>

</MultiDataTrigger>

</Style.Triggers>

</Style>