TimeSpanEditBox background color not working when control's host is disabled.

Editors for WPF Forum

Posted 9 years ago by Piyush Parsai
Version: 15.1.0621
Avatar

Hi,

We have used TimeSpanEditBox in our application.
We have applied below style on this control:

<Style x:Key="timeContentControlSize" BasedOn="{StaticResource contentControlSize}">
<Setter Property="Control.Width" Value="80" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsUpdated}" Value="True">
<Setter Property="Control.Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>

 

This style is working fine until we disable the page in which this controls is hosted.
If the page is disabled instead of coloring its background to yellow it only colors border of control to yellow.

We want to color background of control in both the cases (page enable & page disable) .

We are using follwoing actipro version : 11.1.545.0

Please suggest us solution regarding this issue. How can we achieve the desired behavior.

[Modified 9 years ago]

Comments (5)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you mean the problem only happens when the control is disabled, that's likely due to the default PartEditBox ControlTemplate having this Trigger in it, which overrides anything from a Style trigger:

<Trigger Property="IsEnabled" Value="False">
	<Setter Property="Background" Value="{DynamicResource {x:Static editorsThemes:EditorsCommonDictionary.BackgroundDisabledBrushKey}}" />
	<Setter Property="BorderBrush" Value="{DynamicResource {x:Static editorsThemes:EditorsCommonDictionary.BorderDisabledBrushKey}}" />
	<Setter Property="Foreground" Value="{DynamicResource {x:Static editorsThemes:EditorsCommonDictionary.ForegroundDisabledBrushKey}}" />
</Trigger>

You would either need to redefine the background brush resource there used in general for disabled edit controls, or you would need to clone and redefine the template to exclude that trigger.


Actipro Software Support

Posted 9 years ago by Piyush Parsai
Avatar

Hi,

Could you please share the link, from where i can download default styles/templates; so that i would be able to clone the template.

Version which i am using is : 11.1.545.0

Thanks,

Piyush

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

You don't seem to be associated with your company's account, but if you ask one of your co-workers who is, they can download the default styles and templates if they go to your company's Organization Account page, and then to the Purchases and Licenses tab. A link is available there.


Actipro Software Support

Posted 9 years ago by Piyush Parsai
Avatar

Hi,

We have copied PartEditBox ControlTemplate:

<Style x:Key="{x:Type editors:PartEditBox}" TargetType="{x:Type editors:PartEditBox}">

 Added reference to below style in our application

<Style x:Key="smallContentControlSizeInt32EditBox" TargetType="{x:Type editors:Int32EditBox}" BasedOn="{StaticResource {x:Type editors:PartEditBox}}">

 We are getting below error in application

“System.Windows.Markup.XamlParseException occurred
  Message='Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '220' and line position '40'.
  Source=PresentationFramework
  LineNumber=220
  LinePosition=40
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at StreamEditor.PropertyPage.Controls.Audio_Input_ACP.InitializeComponent() in d:\SVN_Views\NMX7.4a\NMX\Projects\GUI.NET\StreamEditor\ctlProperties\Controls\Promedia\Audio_Input_ACP.xaml:line 1
       at StreamEditor.PropertyPage.Controls.Audio_Input_ACP..ctor() in d:\SVN_Views\NMX7.4a\NMX\Projects\GUI.NET\StreamEditor\ctlProperties\Controls\Promedia\Audio_Input_ACP.xaml.cs:line 24
  InnerException: 
       Message=Cannot find resource named 'smallContentControlSizeInt32EditBox'. Resource names are case sensitive.
       Source=PresentationFramework
       StackTrace:
            at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
            at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
       InnerException:”

 

InnerException is::
Message=Cannot find resource named 'smallContentControlSizeInt32EditBox'. Resource names are case sensitive.

We have checked the style key name and it is mentioned correctly.

Also want to know if we change control template in PartEditBox will it work for

• • int32EditBox
• • timespaneditBox
• • doubleEditBox

Will below code in PartEditBox style will override default background properties if control is disabled.

<ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsUpdated}" Value="True">
                            <Setter Property="Background" Value="Yellow" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>

 

Thanks,
Piyush

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

From the exception, it seems like it could be perhaps that your 'smallContentControlSizeInt32EditBox' isn't in a proper accessible location.  Or I wonder if your BasedOn is wrong.  Maybe try pulling out the BasedOn since the default style should get applied anyhow.

The same template should work with all those edit box controls.


Actipro Software Support

The latest build of this product (v24.1.3) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.