How to change the background of the StackPanel control when any child element has focus?

Hello folks!
I need to change the background of the StackPanel control when any element within the StackPanel has focus. I am executing the code snippet below. The code works fine with elements within the Grid control named "main". It doesn't work when I focus
an element within the Grid control named "header".
<StackPanel x:Name="techReportStackPanel" Width="250" Background="{Binding ColorBrush}" >
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=techReportStackPanel, Path=IsKeyboardFocusWithin}" Value="True">
<Setter Property="Background" Value="Gray" />
<Setter Property="Opacity" Value=".5" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Grid x:Name="header">
<TextBlock x:Name="headerColumn" Text="{Binding Name}" Style="{StaticResource ColumHeader}"/>
<Button Visibility="{Binding ElementName=headerColumn, Path=Text, Converter={StaticResource delButtonVisibilityConverter}}" Command="{Binding DelCommand}" Content="x" ToolTip="{l:Translate TechReportDeleteToolTip}"/>
</Grid>
<Grid x:Name="main">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<wpftoolkit:WatermarkTextBox Grid.Column="0" Style="{StaticResource OrdinaryTextbox}" Watermark="{l:Translate LengthLabel}" ToolTip="{l:Translate BoreholeSpacingInRow}" Text="{Binding BoreholeSpacingInRow, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat=F2, Converter={StaticResource zeroToEmptyDoubleConverter}}" />
<wpftoolkit:WatermarkTextBox Grid.Column="1" Style="{StaticResource OrdinaryTextbox}" Watermark="{l:Translate WidthLabel}" ToolTip="{l:Translate BoreholeSpacingBetweenRow}" Text="{Binding BoreholeSpacingBetweenRow, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat=F2, Converter={StaticResource zeroToEmptyDoubleConverter}}" />
</Grid>
</StackPanel>
Any advice and suggestions will be greatly appreciated!

>>It doesn't work when I focus an element within the Grid control named "header".
You mean when the Button in the "header" Grid is focused? A TextBlock is not focusable so when the Button is not visible no element in the "header" Grid will be focused since you only have two elements in the "header" Grid.
But when the Button is visible it should work. Please refer to the following code:
<StackPanel x:Name="techReportStackPanel" Width="250" Background="{Binding ColorBrush}" >
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=techReportStackPanel, Path=IsKeyboardFocusWithin}" Value="True">
<Setter Property="Background" Value="Gray" />
<Setter Property="Opacity" Value=".5" />
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Grid x:Name="header">
<TextBlock Text="text..."/>
<Button Visibility="Visible" Content="Button" />
</Grid>
<Grid x:Name="main">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0">main grid...</TextBox>
<TextBox Grid.Column="1">main grid...</TextBox>
</Grid>
</StackPanel>
When the Button is focused the Background colour of the StackPanel is set to Gray as expected.
If you want to be able to focus the TextBlock you should set its Focusable property to true:
<Grid x:Name="header">
<TextBlock Focusable="True" x:Name="headerColumn" Text="{Binding Name}" Style="{StaticResource ColumHeader}"/>
<Button Visibility="{Binding ElementName=headerColumn, Path=Text, Converter={StaticResource delButtonVisibilityConverter}}" Command="{Binding DelCommand}" Content="x" ToolTip="{l:Translate TechReportDeleteToolTip}"/>
</Grid>
Hpoe that helps.
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

Similar Messages

  • How do I change the background in the Menu bar screen area so that it is lighter and thus more readable?

    The background in the area where the Menu bar now sits is jetblack.. When I drag, say, the print icon or cut, paste, save icons to sit to the right of the menu bar, they're there but either I see them only faintly (printer) or I cna't see them only faintly. How can I change the background to a lighter color (it used to be much lighter).

    The easiest way might be to install a lightweight theme (formerly known as a persona). You can "shop" for one on the Add-ons site. The following link is for solid colors, but some of the pictorial ones might work, too.
    https://addons.mozilla.org/en-US/firefox/themes/solid
    You can hover your mouse over the little image tile to see how it would look if you installed it. Can you find one that looks good to you?
    Much of Firefox's interface also can be modified with style rules. However, that requires a lot more experimentation, so let's come back to that only if needed.

  • How do i turn off apps running in the background with the new upgrade?

    how do i turn off apps running in the background with the new upgrade?

    They changed it a bit, but you can still close apps. Double click the Home button to pull up the currently running apps. Side scroll over to the app you want to close, then swipe up on the app *window* (not the icon at the bottom).
    = L.I.

  • Changing the background of the pdf form in runtime.

    Dear All,
    I want to change the background of the pdf form in runtime. But I don't need to change the fillcolor. I want to change the background by using the pdf file. That means I want to switch the background of the pdf form on click events.
    I don't know this is possible or not.
    If anybody know how to solve this problem Please suggest me.
    Thank you
    saroj neupane

    I do not believe that it is possible.

  • I'm using Lightroom cc, I'm trying to create a develop preset. I'm making changes to one photo that I want to apply to many other photos, one of the changes is to blur the background using the adjustment brush. When I am blurring I am going over the photo

    I'm using Lightroom cc, I'm trying to create a develop preset. I'm making changes to one photo that I want to apply to many other photos, one of the changes is to blur the background using the adjustment brush. When I am blurring I am going over the photo several times, when I go to create the preset the adjustment brush is not an option to check. How do I add the adjustment brush to the develop presets. Thanks Ron.

    The adjustment brush cannot be added to a develop preset.
    If you can replace the adjustment brush with a gradient filter or radial filter, you can add those to a dev preset.
    If a gradient filter or radial filter is not an option for you, you can at least create an adjustment preset to remember your brush settings.

  • As an update, I installed an update 5.7on my Mac laptop, now the Lightroom 5.0 has become a "Lightroom Mobile" version.  How can change it back to the laptop version?

    As an update, I installed an update 5.7on my Mac laptop, now the Lightroom 5.0 has become a "Lightroom Mobile" version.  How can change it back to the laptop version 5.7?
    Thanks for any help you can provide.

    LR on your laptop is still a desktop version.  It is just now able to upload to the cloud to replicate photos to either http://lightroom.adobe.com/ or an iPad that has LR Mobile installed.
    I think you probably just want to change the LR 5 identity plate back so it doesn’t mention LR Mobile all the time.  Hover over the identity-plate area, and click on the little triangle that appears, then choose Change Identity Plate.

  • How to change a setting in the Java Control Panel with command line

    Hi,
    I am trying to figure out how to change a setting in the Java Control Panel with command line or with a script. I want to enable "Use SSL 2.0 compatible ClientHello format"
    I can't seem to find any documentation on how to change settings in the Java Control Panel via the command line
    Edited by: 897133 on Nov 14, 2011 7:15 AM

    OK figured it out. This is for the next person seeking the same solution.
    When you click on the Java Control Panel (found in the Control panel) in any version of Windows, it first looks for a System Wide Java Configuration (found here: C:\Windows\Sun\Java\Deployment). At this point you must be wondering why you don't have this folder (C:\Windows\Sun\Java\Deployment) or why its empty. Well, for an enterprise environment, you have to create it and place something in it - it doesn't exist by default. So you'll need a script (I used Autoit) to create the directory structure and place the the two files into it. The two files are "deployment.properties" and "deployment.config".
    Example: When you click on the Java Control Panel it first checks to see if this directory exists (C:\Windows\Sun\Java\Deployment) and then checks if there is a "deployment.config". If there is one it opens it and reads it. If it doesn't exist, Java creates user settings found here C:\Users\USERNAME\AppData\LocalLow\Sun\Java\Deployment on Windows 7.
    __deployment.config__
    It should look like this inside:
    *#deployment.config*
    *#Mon Nov 14 13:06:38 AST 2011*
    *# The First line below specifies if this config is mandatory which is simple enough*
    *# The second line just tells Java where to the properties of your Java Configuration*
    *# NOTE: These java settings will be applied to each user file and will overwrite existing ones*
    deployment.system.config.mandatory=True
    deployment.system.config=file\:C\:/WINDOWS/Sun/Java/Deployment/deployment.properties
    If you look in C:\Users\USERNAME\AppData\LocalLow\Sun\Java\Deployment on Windows 7 for example you will find "deployment.properties". You can use this as your default example and add your settings to it.
    How?
    Easy. If you want to add *"Use SSL 2.0 compatible ClientHello format"*
    Add this line:
    deployment.security.SSLv2Hello=true
    Maybe you want to disable Java update (which is a big problem for enterprises)
    Add these lines:
    deployment.javaws.autodownload=NEVER
    deployment.javaws.autodownload.locked=
    Below is a basic AutoIt script you could use (It compiles the files into the executable. When you compile the script the two Java files must be in the directory you specify in the FileInstall line, which can be anything you choose. It will also create your directory structure):
    #NoTrayIcon
    #RequireAdmin
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_UseX64=n
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    Func _JavaConfig()
         $ConfigFile_1 = @TempDir & "\deployment.properties"
         $ConfigFile_2 = @TempDir & "\deployment.config"
         FileInstall ("D:\My Documents\Autoit\Java config\deployment.properties", $ConfigFile_1)
    FileInstall ("D:\My Documents\Autoit\Java config\deployment.config", $ConfigFile_2)
         FileCopy($ConfigFile_1, @WindowsDir & "\Sun\Java\Deployment\", 9)
         FileCopy($ConfigFile_2, @WindowsDir & "\Sun\Java\Deployment\", 9)
         Sleep(10000)
         FileDelete(@TempDir & "\deployment.properties")
         FileDelete(@TempDir & "\deployment.config")
    EndFunc
    _JavaConfig()
    Now if you have SCUP and have setup Self Cert for your organization, you just need to create a SCUP update for JRE.
    Edited by: 897133 on Nov 16, 2011 4:53 AM

  • How do I move from one website to another using Safari, while still allowing Pandora to provide music in the background? It seems that when ever I open a new URL, I lose Pandora.

    How do I move from one website to another using Safari, while still allowing Pandora to provide music in the background? It seems that when ever I open a new URL, I lose Pandora.

    Try running Pandora in its own tab and leaving that tab open (Safari 7.1.5, OS 10.9.5).  I don't have Pandora to try this, but it works for me otherwise.
    Good luck
    srb

  • I need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by ste

    i need to know how to edit a drawing - basically remove the arrows and text but at the same time match the background of the existing pic. then re add new text. how do i erase the arrows and text and arrows but match current background of pic. step by step explanation please beginner

    Please post (a relevant section of) it right on this Forum.

  • How to use a scaled object(MC) to fill the background with the new properties

    So lets say i have a stage 300 to 200 and all object that i have are for this dimensions.Also have an pattern function that fills the background.
    But the user is thinking of resizing the stage to lets say 1024 to 480 (he switched from a phone to a tablet).And now the scale of the objects in the tablet screen are more than 3times before(when seen on the Phone)
    How do i save the current new size object and use it in the creation of the new background (the 1024x480).
    currently i have this :
    public static const GAME_ORG_WIDTH:uint = 300;
    public static const GAME_ORG_HEIGHT:uint = 200;
    public function MainClass_road() {
                                  addEventListener(Event.ADDED, init);
                        public function init(e:Event):void{
                                   stage.scaleMode = StageScaleMode.NO_SCALE;
                                     stage.align = StageAlign.TOP_LEFT;
                                     stage.addEventListener(Event.RESIZE, setUpScreen);
                        public function setUpScreen(ev:Event):void{
                                  stage.removeEventListener(Event.RESIZE, setUpScreen);
                                  if(stage.fullScreenHeight > stage.fullScreenWidth){  
                                            gameStageWidth = stage.fullScreenWidth;
                                gameStageHeight = stage.fullScreenHeight;
                                  }else {
                                            gameStageWidth = stage.fullScreenHeight;       // 480
                                            gameStageHeight = stage.fullScreenWidth;                     //1024
                                  rescaleRatio = gameStageWidth / GAME_ORG_WIDTH;  
                                  //rescale every object, ie:
                                myC.scaleX = myC.scaleY =   rescaleRatio;
                       //start filling the Background with the pattern
                                       tileBgF();
    and then I use the while loop for filling the screen/background
    public function tileBgF(e:Event=null):void {
                                                      var bgClip = MyC;
                                                      var i:int = 0;
                                                      var j:int = 0;
                                                      while (bgClip.x < stage.stageWidth) {
                                                                bgClip = MyC;
                                                                while (bgClip.y < stage.stageHeight) {
                                                                          bgClip = MyC;
                                                                          tileLayer.addChild(bgClip);
                                                                          bgClip.x = bgClip.width * i;
                                                                          bgClip.y = bgClip.height * j;
                                                                          j++;
                                                                j = 0;
                                                                i++;
                                                      addChildAt(tileLayer,0);
    why does it give me
    Line 52
    1120: Access of undefined property MyC.
    in public function tileBgF
    and further more.After filling the background/screen with the pattern , how do i save it all like one big bitMap  so i can use /add it after time without doing all the checking of screen and things again.

    and is it better to use
    stage.fullScreenHeight
    in the while loop or leave it like it is ,or its irrelevant

  • When I drag pdf files into iBooks Author, the background in the pdf file changes into the colour of my book (brown/beige)?

    Hi,
    when I drag a pdf file (when working in Preview) into iBooks Author, the background colour in the pdf file changes into the background colour of the book.
    This happens not consistently, sometimes the background of the pdf file does not change (and stays white), sometimes it's like the text in the pdf file is 'lifted' of the file, and put on the page in iBooks Author (with a brown/beige background).
    All the pdf files are scanned pdf's, nothing comes out of Pages, Word, Excel,...
    Anybody?
    Thanks a lot!
    Wouter

    I have the same question (posted here: https://discussions.apple.com/message/25644741#25644741).
    I believe this is because the PDFs have transparent backgrounds. As far as I can tell, the only way to fix it is to export the PDF as another file, such as an image file. Or perhaps convert it to Word and import it that way.

  • How do i set the background of the table( not of cell / row / column).

    How do i set the background of the table( not of cell / row / column).
    What happens when i load the applet the table is blank and displays the background color is gray which we want to be white.
    We tried using the setBackGround but it is not working maybe we are not using it properly. Any help would be gr8.
    Thanks in advance.

    I don't understand very well, but i guess that the background is gray when the table content's empty, isn't it?
    When the table model is empty, the JTable doesn't paint, so its container displays its background (often gray).
    In this case, what you must do is force the table to paint, even if the model is empty. So, you have to create your own table and override three methods :
    public class MyTable extends JTable
    //specify the preferred and minum size when empty
    myPreferredWidth = 200;
    myPreferredHeigth =200;
    myMinimunWidth = ...;
    myMinimunHeigth = ...;
    public Dimension getPreferredSize()
    if(getModel().getRowCount() < 1)
    return new Dimension(myPreferredWidth, myPreferredHeigth);
    else
    return super.getPreferredSize();
    public Dimension getMinimumSize()
    if( getModel().getRowCount() > 0)
    return new Dimension(myMinimunWidth, myMinimunHeigth);
    else
    return super.getMinimumSize();
    protected void paintComponent(Graphics g)
    if (getModel().getRowCount<1 && isOpaque()) { //paint background
    g.setColor(Color.white);
    g.fillRect(0, 0, getWidth(), getHeight());
    else super.paintComponent(g);
    }

  • How do I set the stage (or the background in the stage?) to be transparent?

    How do I set the stage (or the background in the stage?) to be transparent?
    Thanks
    Gary

    Select Stage.
    Color Swatch
    Then set the Alpha slider to 0.
    Darrell

  • How to change a connection with the database in Runtime?

    How to change a connection with the database in Runtime?
    My connection was made using ADF Business component (ApplicationModule).
    ADF Swing.
    JDeveloper Studio 11.1.1.4.0.

    When deploying ADF applications with database connection, you should be using JDBC data sources configured in the weblogic server.
    You could change the JDBC data sources to a different DB instance or location - by changing the JDBC data source and restarting the weblogic server.
    For more details, check
    http://techiecook.wordpress.com/2010/12/02/oracle-weblogic-adf-datasources/
    Thanks,
    Navaneeth

  • Aperture 3: After sending my book for printing to Apple the Apple Store told me that my text and the background have the same color and they couldn't print the book. But I couldn't find any problem in the preview. How could I find the problem pages?

    Aperture 3: After sending my book for printing to Apple the Apple Store told me that my text and the background have the same color and they couldn't print the book. But I couldn't find any problem in the preview. How could I find the pages where the problems are? Or otherwise, why doesn't print Apple the book how it is. Idon't need the text which couldn'be seen.

    The forum is for Logic Pro users.. I will ask the moderators to move it to a more appropriate forum for your question/subject
    Cheers..

Maybe you are looking for

  • Ctrl + e and command + e stopped working

    I've seen a few other discussions about ctrl + e not working but none of them fit the problem I'm having here. On http://www.clarkwfobes.com I have ICE set up. I've been editing before and so has the client so it was working with no problem. Now when

  • CRM- Two Z tabs with the same name

    Hello, We have a problem with 2 new tabs in a sales contract in CRM. In the sales contract, we have created two tabs, one 1 and 2, and the problem is the name of the tab, that is the same for both, althoung the fields in the tabs are different and fi

  • How can I upload digital video from a HDD camcorder to iMac Intel?

    I bought a Sony DCR SR100 camcorder with 30 gig HD, and the software that comes with it is Windows only, and the Mac software that they refer you to on the internet says "not Intel Core compatible" So get this - the online support guy from Sony says

  • Accounting doc in Good Receipt

    Dear Sir,           I have a Material having price control as Moving average price. Now I have made a PO with 100 qty with different price rather than mvp.Then I have done the MIGO for 30 qty.In accounting view there should be stock account and gr/ir

  • Multiple services listening to AQ

    Hello everyone, If there is more than one service pulling data from an AQ, how can we find out which service has pulled the data? Is there anyway to find out what are all the services that are listening to an AQ? Any specific log file or data diction