.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Problem setting Foreground with Visual State Manager (WPF - .Net v4.0

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :WPF
0 down vote favorite I have a WPF application, and I am attempting to style a TextBox using the .Net v4 Visual State Manager. Specifically, I am attempting to set the colors of the Foreground and Background for the MouseOver state. What is happening is that, while the background and border are changing perfectly, the foreground is not. If the brushes that I am using get their color via a StaticResource, then the foreground does not change at all. If the brushes that I am using get their color via a DynamicResource, then when I mouse over a TextBox, the foreground of all TextBoxes change. Clearly, either I'm doing something wrong, or what I want to do is simply not possible with VSM (which would be rather disappointing). Here are the resources that I am using:   <Color x:Key="ControlBackgroundColor" R="178" G="178" B="178" A="255" />  <Color x:Key="ControlForegroundColor" R="0" G="0" B="0" A="255" />  <Color x:Key="BorderColor" R="127" G="127" B="127" A="255" />  <Color x:Key="MouseOverControlBackgroundColor" R="0" G="0" B="0" A="255" />  <Color x:Key="MouseOverControlForegroundColor" R="255" G="2

View Complete Post

More Related Resource Links

Visual State Manager conflicts with WPFtoolkit.

how can i get the wpftoolit to work together with framework 4.0? when i add a VisualStateManager item to my xaml-file in vs 2010 i get the following error: The type 'System.Windows.VisualStateGroup' exists in both 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\PresentationFramework.dll' and 'c:\Program Files (x86)\WPF Toolkit\v3.5.50211.1\WPFToolkit.dll' thanks for your help regards

InvalidOperationException in VS2010 WPF Designer on Visual State Manager



When adding WPF styles through control templates and resourcedictionarys VS2010 throws an InvalidOperationException error in the designer on controls when certain properties are set, that link back to the Visual States. I thought this must be the way i was creating the Visual States (i am using Blend 4.0) but I am also getting the same error, even using the ControlTemplateExamples downloaded from the msdn site.  http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7741

I opened up the solution in VS2010, then opened MainWindow.xaml (split screen - designer and markup)


'System.Windows.Media.Animation.ColorAnimation' animation object cannot be used to animate property 'Foreground' because it is of incompatible type 'System.Windows.Media.Brush'.

... there are 11 errors but the solution builds successfully and runs fine.

If you look at the markup in MainWindow.xaml and the first set of buttons, the first error is linked to the "IsEnabled" property

SQL Server Session state problem.


Hi to all,

I have some things that I want to know. I am right now using a free asp.net webhosting ("somee.com"). The problem is that when I am visiting a page, there's a tendency that values stored in my session variables are lost. Therefore, it causes an error when the requested page is loaded.

1. I am thinking of using sessionState mode="SqlServer". Will it solve my problem?

Actualy Im working on it but Im having problems when connecting to the sql database.

2.  Is that a problem in the webhost?

3. Do free webhosting sites provide allow session state in the sql server?. Because ive tried it locally into my computer and error say's i should intall the ASP.NET Session State SQL Server version 2.0 or above.

browser gives jibberish when State manager (sql) is turned on


Hi all, we're testing our web app with a state manager so that we can do distributed rollouts. We're not getting any errors, but we are getting jibberish returned for every page request. 

(it won't even let me paste it in here)

HOw do I get it to serve the pages normally?


Error while setting up application on Win7 using Visual Studio.NET 2003


Hi All,

Getting the below error while setting up application on Win 7 using visual studio.NET 2003.


cannot find the components for communiacting with the front page server extensions...


I understand by the error, i need to install Front page server extension, but not able to figure how to install using IIS 7.5.

I had XP machine with IIS 5.1, able to find the option.


Need your help in resolving this.




Extreme ASP.NET: A New Solution to an Old State Storage Problem


State management in Web applications is a contentious issue. Should you store user data per session or should you persist it across sessions? You can easily store information temporarily while someone navigates your site by using session state.

Fritz Onion

MSDN Magazine April 2006

Session State Problem




I just for the first time into a session state problem. So I am hoping someone

here has the answer.


I have written an ASP.Net website and tried to implement the common poor mans online user count.
The problem I am having is the following.

On App_Start I create a variable and assign it the value of 0;

Then increase the number on session_start and decrement on session_end.

On my local IIS it works perfectly from IE8 and Opera. The value increments correctly.
As soon as I upload to my live server. The value increments on every link I click and every page refresh when I test with IE8.
This does not happen when testing with Opera.

Could someone please shed some light on the subject.




Louis Lews

Visual Studio designer event problem


Hi there

I have a small issue that I'm sure others have experienced - but haven't yet found a solution / workaround for this.

When adding controls to Visual Studio in designer you normally get a event button (the yellow flash light) in the properties window.

But when you nest a button inside a placeholder (for example) you cannot mark the button from the designer - only the placeholder! When trying to go into "split-view" on the designer you'll be able to mark the button in the bottom of the designer - but only properties and not the event button appers in the properties window!

I know that you can go into codebehind and manually add the event but I thiink it is really tiresome to do so if I don't have to...

I had a small hope that VS2010 the issue would be gone but sadly it isn't...

Anyone ever found a solution for this one?

Kind regards Thomas

Excel Connection Manager Problem

I am building a package that has 2 tasks that need to use the same excel connection manager. I use a execute sql task to dynamically build a table from the headers of the excel sheet  ,then I use an excel source component to load the data from the sheet. However when I try to edit the excel source and switch the data access mode to a variable and select the variable(for the path), when I try to close the editor I get this message 'S:\myfolder'.  It is already opened exclusively by another user, or you need permission to view its data. I need this package to access the same folder each time because the files will be placed in that folder. This package also has a branch for loading a text file into sql server. It access the same folder but uses a flatfile connection manager It looks like permissions on the folder are correct

problem on Page_PreRender with RangeValidator control and programmatically setting Maximum and Minim

I am new to the ASP.NET /C# dev. I run into a weird bug when using the RangeValidator Control inside a Formview. I have my DateTime field with validator and it work fine until I submit the page, it actually insert the row into the database but then when the page reload I get the following exception.Server Error in '/Budget' Application. The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'.] System.Web.UI.WebControls.RangeValidator.ValidateValues() +1077011 System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid() +12

Visual Studio 2010, MVC2.0, IIS7, .NET4 deployment problem

I have a problem where I can get an MVC2.0 application using .NET3.5 running in IIS, but when I upgrade it to .NET4.0, the browser just reports error 500 Internal Server Error. The problem is easy to replicate as follows.  Firstly, to show it works with .NET3.5: Create a new MVC2.0 application in Visual Studio 2010, using the inbuilt starter template. Run the application using the development server, and the Home & About pages display fine. Publish the application to a directory. Copy the directory to a subdirectory under inetpub/wwwroot on my Vista computer, running IIS7 Create a new application in IIS Manager & select the DefaultAppPool (integrated pipeline) Browse the application and Home & About pages are displayed. Then the problem I have is after upgrading to .NET4.0: Change to .NET4.0 for the project in Visual Studio Build & this runs fine with the development server. Publish the application & set up IIS as before, except choosing the application pool ASP.NET v4.0 (integrated pipeline) Browse the application, and I get the 500 Internal Server Error I'm guessing there is some extra configuration required - can anyone help? I've deliberately used the default MVC installation to eliminate any variables caused by my programming .. Thanks in advance, Steve

Problem With Using Trigger for Setting Label Content

Basically, I have a label and depending on the Object type of the current data source item I want to control what the content of the label is. The trigger I am trying is: <Label Margin="222,21,242,134" Name="MyLabel"> <Label.Resources> <DataTrigger Binding="{Binding Path=/EntryType}" Value="Object.Type1" x:Key="myTrigger"> <Setter TargetName="MyLabel" Property="Content" Value="{Binding Path=/Object.Property1}"/> </DataTrigger> </Label.Resources> </Label> The problem is that I am getting this error: 'Content' member is not valid because it does not have a qualifying type.   Do I need to use some sort of converter or something? Or am I aproaching this worng?

SSRS 2008 R2 Problem understanding View State Validation steps

Hi, Sorry, but I have some problem understanding this steps. Please help me to understand this.  Pasted from http://technet.microsoft.com/en-us/library/cc281307.aspx?lc=1033 How to Configure View State Validation To run a scale-out deployment on an NLB cluster, you must configure view state validation so that users can view interactive HTML reports. You must do this for the report server and for Report Manager. View state validation is controlled by the ASP.NET. By default, view state validation is enabled and uses the identity of the Web service to perform the validation. However, in an NLB cluster scenario, there are multiple service instances and web service identities that run on different computers. Because the service identity varies for each node, you cannot rely on a single process identity to perform the validation. To work around this issue, you can generate an arbitrary validation key to support view state validation, and then manually configure each report server node to use the same key. You can use any randomly generated hexadecimal sequence. The validation algorithm (such as SHA1) determines how long the hexadecimal sequence must be. Generate a validation key and decryption key by using the autogenerate functionality provided by the .NET Framework. (Well, how to generate Validation key using .Net Framework?) In the end, you must have a singl

change TD background/foreground color problem.

I have some javascript that is suppose to change the color of a table TD. the CSS file has an entry like this .tdcommand {} HTML TD is like <td colspan="2" height="162" valign="top" class="tdcommand"> if i put a background-color:red or whatever in the CSS file, the color is shown correctly. If i change it via a script it doesnt seem to have any impact. using the alert() to post info, i've found its entering my function correctly and getting the correct info. the important part of the function is thisfor (var i = 0; i < document.styleSheets[0][CSSRules].length; i++) { if (document.styleSheets[0][CSSRules][i].selectorText == obj) { document.styleSheets[0][CSSRules][i].style[prop] = color document.getElementById("opt_" + option).innerHTML = "'" + color + "'" } }   as i said, using the alert() i can validate that its finding the class ok (obj = .tdcommand) and the property is correct (background-color) and the innerHTML update is working fine. I use this same function to set other things, such as text color and highlighting of span's without any problem. what am i missing?   Justin

Setting / Selecting state by hand

Is it possible to change the current statte of a running workflow to another activity without direct connections between them? The scenario is: WF4 with AppFabric is used as a workflow engine on a customer server, running custom workflows. The workflows consist of activities with human interaction Wih an monitoring/administration tool the administrator can supervise the running workflows If in one workflow something did not work as wanted the administrator can set the next activity to any of the previous ones of his own chosing. Thanks Florian

Hover State styling problem...

Here is a link to a screenshot of the off state... http://www.spasticgoat.com/shareshot.jpg when I hover over one of them, it activates a blue gradient background image in the tabs, which I can't get rid of! I've been trying to just use: background-image: none; and then assign a background color to the hover state, but it's not happening.   Any ideas?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend