Set border color of editable ComboBox on focus

What I want to do, is set BorderBrush of editable ComboBox. I'm using slightly modified default WPF templates. They are structured like below:
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" ...>
<ToggleButton x:Name="toggleButton" ... />
<Border x:Name="border" ...>
<TextBox x:Name="PART_EditableTextBox" ... />
<!-- textbox with IsFocused property which should be focus trigger -->
</Border>
</Grid>
</ControlTemplate>
ToggleButton template:
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot" ...> <!-- first border brush I want to set on focus -->
<Border x:Name="innerBorder" ...> <!-- second border brush I want to set on focus -->
<Border x:Name="splitBorder" ...>
<Path x:Name="arrow" ... />
</Border>
</Border>
</Border>
</ControlTemplate>
And now, what should happen.
When PART_EditableTextBox.IsFocused is equal to true then set
templateRoot.BorderBrush and innerBorder.BorderBrush to another color (for example red and blue).
It would be very simple if there was only one BorderBrush to set, because I could use
TemplateBinding to bind this property to ToggleButton element.
For me, the problem are nested templates. I don't know how to refer to inside of another template.
I hope you can help me.
It would be very good if I didn't need to use C# code, just XAML.

>>I don't know how to refer to inside of another template.
You cannot. But since the PART_EditableTextBox is part of the ControlTemplate of the ComboBox you could add the trigger to this control template and then for example set the BorderBrush property and the Background propery of the ToggleButton and bind these
to the BorderBrush properties of the Borders in its ControlTemplate:
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
<TextBox x:Name="PART_EditableTextBox" ... />
<ToggleButton x:Name="toggleButton" ... />
<ControlTemplate.Triggers>
<Trigger Property="IsFocused" Value="True" SourceName="PART_EditableTextBox">
<Setter Property="BorderBrush" TargetName="toggleButton" Value="Red"/>
<Setter Property="Background" TargetName="toggleButton" Value="Blue" />
</Trigger>
</ControlTemplate.Triggers>
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="2">
<Border x:Name="innerBorder" BorderBrush="{TemplateBinding Background}" BorderThickness="2">
<Border x:Name="splitBorder">
<Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}"
Fill="Black" HorizontalAlignment="Center" Margin="0,1,0,0" VerticalAlignment="Center"/>
</Border>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If you don't want to use the Background property for this, the other option is to create your own custom class that derives from the ToggleButton class and add a dependency property called "InnerBackground" or something to this class and replace
the ToggleButton with your custom ToggleButton and replace the binding to the Background property with a binding to the new dependency property and set this one in the control template for the ComboBox.
Hope that helps.
Please remember to close your threads by marking helpful posts as answer and/or helpful and please start a new thread if you have a new question.

Similar Messages

  • How to set Border Color for Screens in WebDynpro?

    Hi friends,
    I was actually working on an application involving many screen Layouts.
    After the designing of these Screens i have observed that on all the four borders of the screen are left with white as the background.So i just wanted to know whether we can select the choice of Border of the screen.
    Please do let me know about this problem.
    Thanks and regards,
    Chandrashekar.

    Hi,
    in case your deploying in a portal the WDJ might sport the Portal theme else you'll have to take at look at editing Web Dynpro Themes.
    See <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/how%20to%20edit%20web%20dynpro%20themes.pdf">How to edit Web Dynpro Themes</a>.
    regards,
    Bernd

  • Report Generation broken after deployment - Excel Set Cell Color and Border.vi

    Upon deployment, the Excel Set Cell Color and Border.vi became broken.  After installing LV2010 SP1 to view the VIs in the deployment, I noticed that in the second case structure where the code draws the border using the BorderAround invoke node, there is an extra variant input parameter named 'Parameters'.  Upon right-clicking, an option to 'Relink Invoke Node' appeared and after selecting this, the extra input disappeared and the VI was no longer broken.
    Why does "Relink Invoke Node" appear?  How do I create a deployment with this issue?  Has anybody else experienced this?  Why is the TestStand deployment so buggy?  

    Hi Ching-Hwa,
    I have set up a test deployment here where I am deploying a workspace that contains a sequence file.  This sequence file has a LabVIEW Action Step calling a VI that opens a new Excel file and simply calls the Excel Set Cell Color and Border VI.  After deploying this, both the VI and my test sequence ran on the deployment machine without error.  Therefore, I do have some more questions to more accurately reproduce what you are seeing.
    First, what operating systems are you developing on and deploying to?  Also, what license do you have for TestStand on the machine you are deploying to?  If you have a development version, can you manually take the sequence file and VI to this machine and run it?  I know you now have LabVIEW 2010 SP1 on your development machine, but if you have the development version of TestStand as well, it would be interesting to see if you copy the files over if you still see this behavior.  Are you including the TestStand Engine in the deployment?
    Can you open a blank VI on the deployment machine and add the Excel Set Cell Color and Border VI?  It would also be interesting to see if this is not a product of the deployment, but rather an issue with something on the deployment machine itself.  What version of the Report Generation Toolkit do you have on each machine?  Also, what versions of Excel are you using on the development and deployment machine?  Again, it would be helpful for me to know exactly what versions you have installed on both the development and deployment machines so that I can reproduce this as accurately as possible.
    One last thing to try, too, would be to try deploying the VI by itself just to see if it also has the same behavior.  Do you have the Application Builder in LabVIEW?  If so, could you also try building an executable from the VI, create an installer, and deploy this to the deployment machine?  
    In regards to the "freezing" of code by removing the block diagrams, I do not believe this will be a proper work around in this case.  While this removes the block diagram from actually being deployed along with the VI and restricts users from editing the code on the deployment machine, if something is getting changed in the compiled code upon deployment, this will not stop this from happening.  This option is available more as a memory option to lower the size of the deployment as well as prohibit any users on the development machine from editing the block diagram themselves.    
    Thanks, Ching-Hwa!  I look forward to your response so that I can continue trying to reproduce this issue.  Have a great day! 
    Taylor G.
    Product Support Engineer
    National Instruments
    www.ni.com/support

  • Set control border color for tabbing

    Is there a way to set the color of the border when tabbing through controls? Right now I have a darker background so it doesn't do much good to be tabbing through enum and ring dropdowns when you can't tell which is selected because the border is black.
    CLA, LabVIEW Versions 2010-2013

    Here is a post that talks about how to hide the key focus:
    http://forums.ni.com/t5/LabVIEW/How-do-I-get-rid-o​f-the-Key-Focus-object-border/m-p/844383
    Maybe Label.TextColor can be changed when the focus is on the numeric control or blink the control.
    Jst some ideas until border color change is provided in LV.
    CLD,CTD

  • Losing focus on editable combobox

    Hi everyone!
    I have created a combobox and setEditable is set to true but it does not react to the focus lost method.But when the setEditable is set to false then the focus lost method is executed. According to the following Sun Developer sites(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6433257,
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4628933) this is some kind of bug.
    Is there no way that I can have an editable combobox that reacts to the focus lost method I mean that loses focus?

    When you have an editable combo box the editor has focus, not the combox box. So I guess you would need to add the FocusListener to the editor itself and not the combo box directly.

  • Xmonad focused window border color? =)

    hey guys,
    kind of a xmonad noob, but loving it. currently my focused window's border color is red, which variable do you usually change to swap the colors? tried a few things but nothing worked. should I post my .hs?
    thanks
    sleepy 1

    take a look here to see how simple your xmonad.hs can be, then look at the bottom of this to get the specific functions (variables) available in the main-do block.
    Last edited by brisbin33 (2010-04-28 18:43:32)

  • I have never used my mac for desktop publishing before and am having some problems.  This sounds really dumb, but I can't figure out how to put a border around a text box.  Also, how do you edit the border, i.e. border color, thickness, etc. Help!

    I have never used my mac for desktop publishing before and am running into some real problems.  How do you put a border around a text box?  Can you edit the border - color, thickness, etc.?  Help!

    I think the best solution is to read Pages documentation, go to Help and you have a long list of options. Pages is capable of quite sophisticated things, some features are above Nisus or Mellel, so it is not so simple to summarize things in a few lines.

  • Excel Set Cell Color and Border.viのbackground color 設定について

    お世話になっております。
    Microsoft オフィス用レポート生成ツールキットを使って
    LabVIEWで収集したデータをExcelファイルで出力しようと考えています。
    そこで質問が有ります。
    題名のようにExcel Set Cell Color and Border.viのbackground color 設定についてです。
    デフォルト(未配線)では白に設定されていますが、”色なし”に設定するにはどうしたら良いのでしょうか?
    又、罫線色等を指定する数値設定に関しては、何処を調べたら良いのでしょうか?
    ご教授の程、宜しくお願い致します。

    _YN 様
    平素よりNI製品をご利用頂きまして誠にありがとうございます。
    日本ナショナルインスツルメンツ技術部の湧川と申します。
    ご質問にお答え致します。
    色なしにしたいとの事ですが、こちらでExcel Set Cell Color and Border.viを使用して簡単なVIを実行させてみましたが色なしに設定することはできませんでした。
    そこで質問したいのですが色なしにする理由というのはバックグラウンドが白のままだとセルの枠が見えなくなるからでしょうか。
    もしそうであれば設定により枠をつけることができますのでそちらの方を試して頂けたらと思います。
    方法としましては同じExcel Set Cell Color and Border.viを使い設定します。
    アイコンの上部にピンク色のピンが2つあるかと思いますがそちらからセル内側の線、外側の線を設定できます。
    添付した画像を参照して下さい。
    画像のように設定しますとセルに黒色の枠ができると思います。
    数値設定などに関しても質問されていますが、そちらはヘルプがありますのでそちらを参照頂けると詳しい情報がわかるかと思います。
    LabVIEWでVIを開いている時に ctrl + H を押しますと小さいウィンドウ「詳細ヘルプ」が立ち上がります、その状態でマウスのポインタをアイコンに重ねて頂きますと詳細ヘルプにアイコンの説明が記述されます。
    ウィンドウズ内のリンクからオンラインヘルプを参照することもできます。
    上記内容をご確認いただきまして、何かS_YN様の意図と違う点などありましたらご連絡下さい。
    宜しくお願い致します。
    日本ナショナルインスツルメンツ株式会社
    技術部
    湧川 朝満
    添付:
    Excle Set Color Sample.JPG ‏58 KB

  • Set background color to inside of the border in JPanel.

    Hi all,
    I want to set background color for JPanel with in the TitledBorder limit.
    Thanks in Advance.
    Siddhes.

    >
    I want to set background color for JPanel with in the TitledBorder limit.>Here is another approach..
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    class ColoredInnerPanel {
      public static void main(String[] args) {
        JPanel coloredPanel = new JPanel();
        coloredPanel.setBackground(Color.RED);
        coloredPanel.setPreferredSize( new Dimension(300,400) );
        JPanel outerPanel = new JPanel(new BorderLayout());
        outerPanel.add( coloredPanel );
        outerPanel.setBorder(new TitledBorder("I See Red"));
        JOptionPane.showMessageDialog(null, outerPanel);
    }

  • Hw do i set background color for ComboBox?

    If anyone knows how to set background color for disabeld (setEnabled(false)) of ComboBox in Windows Look and Feel. It will help me a lot.
    I don't know hoe to do it
    regards
    arun.

    At the start of your program add:
    UIManager.put("ComboBox.disabledBackground", Color.green);
    UIManager.put("ComboBox.disabledForeground", Color.blue);For a list of all the properties you can change with the UIManager see:
    http://www.discoverteenergy.com/files/ShowUIDefaults.java

  • How to set a colored Border in ALV OO aroung a row

    Hi there,
    i would like to know if it is possible to set a colored border around an entier row.
    I tried to debug er_data_change_protokol to figuere out how they do their cell bordering but i wasn't successful. Inet an FoSe didn't neither reveal anything, so befor i waste more time i ask the pro's.
    thanks in advance
    mathias

    Also refer:
    [http://abaplovers.blogspot.com/2008/05/changing-color-of-alv-grid-in-sap-abap.html]

  • On value selected in dropdown, set border and border color to subform

    Ok, I'm busy creating a form which has a dropdown field. There are five values inside the dropdown. I also have four subforms which contain tables and fields for each option in the dropdown except the first one. Now I want to set the border and border colour of the subform when the right value is chosen.
    In the exit part I created the code as follows:
    if (this.rawValue == "5"){
         this.resolveNode("TextfieldName").presence = "visible"; //This sets a text to visible...works like a charm
         Optie1.ui.oneOfChild.border.color.value = "255,153,0"; //After an example I found from Niall
         Optie1.ui.oneOfChild.border.color.thickness = "0.0200in";
    I changed this into Optie1, that's the name of the subForm. Somehow it doesn't apply it on the subform. I know I'm doing something wrong, but can't quite find what I want on the forums. Anyone any idea on this?

    Okay, managed to solve this myself by playing around a bit with the code.
    It should be:
    Optie1.border.edge.color.value and Optie1.border.edge.thickness.

  • Wpf Text Box , Is set to mandatory and need to change border color .

    Hi,
    In wpf application . We a text box as mandatory and set the border color as red . We need to change the color to black when user enter values .
    How to do that in xaml page .
    Thank YOu

    Hi Jeevan,
    you could use a Style with a trigger for that.
    <Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
    <Style TargetType="TextBox" x:Key="TextBoxMandatoryStyle">
    <Style.Triggers>
    <Trigger Property="Text" Value="">
    <Setter Property="BorderBrush" Value="Red"/>
    </Trigger>
    </Style.Triggers>
    </Style>
    </Window.Resources>
    <Grid>
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <TextBox Grid.Row="0" Style="{StaticResource TextBoxMandatoryStyle}"/>
    <TextBox Grid.Row="1" Style="{StaticResource TextBoxMandatoryStyle}"/>
    <TextBox Grid.Row="2" />
    </Grid>
    </Window>
    Thomas Claudius Huber
    "If you can't make your app run faster, make it at least look & feel extremly fast"
    My latest Pluralsight-courses:
    XAML Layout in Depth
    Windows Store Apps - Data Binding in Depth
    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com

  • NI_Excel.Ivclass:Excel Set Cell Color and Border.vi Error

    Hi
    I was trying to compile a file and I kept getting an error. It zeroed in on the vi that was not compiling. I am attaching the vi to this message. The vi seems to be broken. And I am not sure how to fix this. Can some one please help me out with this. Thanks in advance. 
    I guess it is associated with Report Generation Toolkit. Please let me know if you need any more details.
    This is the error message 'One or more required inputs to this function are not wired or are wired incorrectly. Show the Context Help window to see what the connections to this function should be.'
    Regards
    Mr Miagi
    Solved!
    Go to Solution.
    Attachments:
    Excel Set Cell Color and Border.vi ‏20 KB

    http://forums.ni.com/t5/LabVIEW/Set-excel-cell-color-and-border-broken-can-t-build-application/m-p/1...
    Please do a search.

  • Excel Set Cell Color and Border VI

    您好,
    請問如果不小心更改到Excel Set Cell Color and Border VI的內容,應如何復原?
    謝謝!!!
    已解決!
    轉到解決方案。
    附件:
    Excel Set Cell Color and Border.jpg ‏231 KB

    http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/zht/pg/1/sn/catnav:du/q/report%20genera...
    以下載點除了 labview 2012 report generation toolkit 以外
    其他都是 patch 檔
    如果您有購買正式版,也許您可以跟 NI 客服部求救

Maybe you are looking for