KeyListener on combobox calander not working?

Am trying to add keylistener on this combobox calander, but somehow its not working right. The calendar is added to a JTable and the keyListener on it works, when i gets focus, but when the popup is visible it looses the keylistener? Can someone help me with this?
import com.sun.java.swing.plaf.motif.*;
import com.sun.java.swing.plaf.windows.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.table.*;
public class DateComboBox extends JComboBox
    public DateComboBox()
    public DateComboBox(int raekke,DefaultTableModel model,JTable tabel)
        this.raekke=raekke;
        this.model=model;
        this.tabel=tabel;
    public void setDateFormat(SimpleDateFormat dateFormat)
        this.dateFormat = dateFormat;
    public void setSelectedItem(Object item)
        // Could put extra logic here or in renderer when item is instanceof Date, Calendar, or String
        // Dont keep a list ... just the currently selected item
        removeAllItems(); // hides the popup if visible
        addItem(item);
        super.setSelectedItem(item);
    public void setText(String texte)
        setSelectedItem(texte);
    public String getText()
        return (String)this.getSelectedItem();
    public void setRaekke(int raekke)
        this.raekke=raekke;
    public void updateUI()
        ComboBoxUI cui = (ComboBoxUI) UIManager.getUI(this);
        if (cui instanceof MetalComboBoxUI)
            cui = new MetalDateComboBoxUI();
        } else if (cui instanceof MotifComboBoxUI)
            cui = new MotifDateComboBoxUI();
        } else if (cui instanceof WindowsComboBoxUI)
            cui = new WindowsDateComboBoxUI();
        setUI(cui);
    // Inner classes are used purely to keep DateComboBox component in one file
    // UI Inner classes -- one for each supported Look and Feel
    class MetalDateComboBoxUI extends MetalComboBoxUI
        protected ComboPopup createPopup()
            return new DatePopup( comboBox );
    class WindowsDateComboBoxUI extends WindowsComboBoxUI
        protected ComboPopup createPopup()
            return new DatePopup( comboBox );
    class MotifDateComboBoxUI extends MotifComboBoxUI
        protected ComboPopup createPopup()
            return new DatePopup( comboBox );
    // DatePopup inner class
    class DatePopup implements
    ComboPopup,
    MouseMotionListener,
    MouseListener,
    KeyListener,
    PopupMenuListener
        public DatePopup(JComboBox comboBox)
            this.comboBox = comboBox;
            setFocusable(true);
            addKeyListener(this);
            calendar = Calendar.getInstance();
            // check Look and Feel
            background = UIManager.getColor("ComboBox.background");
            foreground = UIManager.getColor("ComboBox.foreground");
            selectedBackground = UIManager.getColor("ComboBox.selectionBackground");
            selectedForeground = UIManager.getColor("ComboBox.selectionForeground");
            initializePopup();
        //========================================
        // begin ComboPopup method implementations
        public void show()
            try
                // if setSelectedItem() was called with a valid date, adjust the calendar
                calendar.setTime( dateFormat.parse( comboBox.getSelectedItem().toString() ) );
            } catch (Exception e)
            {e.printStackTrace();}
            updatePopup();
            popup.show(comboBox, 0, comboBox.getHeight());
        public void hide()
            popup.setVisible(false);
        protected JList list = new JList();
        public JList getList()
            return list;
        public MouseListener getMouseListener()
            return this;
        public MouseMotionListener getMouseMotionListener()
            return this;
        public KeyListener getKeyListener()
            return null;
        public boolean isVisible()
            return popup.isVisible();
        public void uninstallingUI()
            popup.removePopupMenuListener(this);
        // end ComboPopup method implementations
        //======================================
        //===================================================================
        // begin Event Listeners
        // MouseListener
        public void mousePressed( MouseEvent e )
        // something else registered for MousePressed
        public void mouseClicked(MouseEvent e)
        public void mouseReleased( MouseEvent e )
            if (!SwingUtilities.isLeftMouseButton(e))
                return;
            if (!comboBox.isEnabled())
                return;
            if (comboBox.isEditable())
                comboBox.getEditor().getEditorComponent().requestFocus();
            else
                comboBox.requestFocus();
            togglePopup();
        protected boolean mouseInside = false;
        public void mouseEntered(MouseEvent e)
            mouseInside = true;
        public void mouseExited(MouseEvent e)
            mouseInside = false;
        // MouseMotionListener
        public void mouseDragged(MouseEvent e)
        public void mouseMoved(MouseEvent e)
        public void keyPressed(KeyEvent e)
            if(e.getSource()==this)
                if(e.getKeyCode()==KeyEvent.VK_CONTROL)
                    System.out.println("keytyped1");
        public void keyTyped(KeyEvent e)
        public void keyReleased( KeyEvent e )
            if(e.getKeyCode()==KeyEvent.VK_CONTROL)
                System.out.println("keytyped2");
            if ( e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER )
                togglePopup();
         * Variables hideNext and mouseInside are used to
         * hide the popupMenu by clicking the mouse in the JComboBox
        public void popupMenuCanceled(PopupMenuEvent e)
        protected boolean hideNext = false;
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
            hideNext = mouseInside;
        public void popupMenuWillBecomeVisible(PopupMenuEvent e)
        // end Event Listeners
        //=================================================================
        //===================================================================
        // begin Utility methods
        protected void togglePopup()
            if( isVisible() || hideNext)
                hide();
            else
                show();
            hideNext = false;
        // end Utility methods
        //=================================================================
        // Note *** did not use JButton because Popup closes when pressed
        protected JLabel createUpdateButton(final int field, final int amount)
            final JLabel label = new JLabel();
            final Border selectedBorder = new EtchedBorder();
            final Border unselectedBorder = new EmptyBorder(selectedBorder.getBorderInsets(new JLabel()));
            label.setBorder(unselectedBorder);
            label.setForeground(foreground);
            label.addMouseListener(new MouseAdapter()
                public void mouseReleased(MouseEvent e)
                    calendar.add(field, amount);
                    updatePopup();
                public void mouseEntered(MouseEvent e)
                    label.setBorder(selectedBorder);
                public void mouseExited(MouseEvent e)
                    label.setBorder(unselectedBorder);
            return label;
        protected void initializePopup()
            JPanel header = new JPanel();
            header.setLayout(new BoxLayout(header, BoxLayout.X_AXIS));
            header.setBackground(background);
            header.setOpaque(true);
            JLabel label;
            label = createUpdateButton(Calendar.YEAR, -1);
            label.setText("<<");
            label.setToolTipText("Sidste �r");
            header.add(Box.createHorizontalStrut(12));
            header.add(label);
            header.add(Box.createHorizontalStrut(12));
            label = createUpdateButton(Calendar.MONTH, -1);
            label.setText("< ");
            label.setToolTipText("Sidste m�ned");
            header.add(label);
            monthLabel = new JLabel("", JLabel.CENTER);
            monthLabel.setForeground(foreground);
            header.add(Box.createHorizontalGlue());
            header.add(monthLabel);
            header.add(Box.createHorizontalGlue());
            label = createUpdateButton(Calendar.MONTH, 1);
            label.setText(" >");
            label.setToolTipText("N�ste m�ned");
            header.add(label);
            label = createUpdateButton(Calendar.YEAR, 1);
            label.setText(">>");
            label.setToolTipText("N�ste �r");
            header.add(Box.createHorizontalStrut(12));
            header.add(label);
            header.add(Box.createHorizontalStrut(12));
            popup = new JPopupMenu();
            popup.setBorder(BorderFactory.createLineBorder(Color.black));
            popup.setLayout(new BorderLayout());
            popup.setBackground(background);
            popup.addPopupMenuListener(this);
            popup.add(BorderLayout.NORTH, header);
            popup.getAccessibleContext().setAccessibleParent(comboBox);
        // update the Popup when either the month or the year of the calendar has been changed
        protected void updatePopup()
            monthLabel.setText( monthFormat.format(calendar.getTime()) );
            if (days != null)
                popup.remove(days);
            days = new JPanel(new GridLayout(0, 7));
            days.setBackground(background);
            days.setOpaque(true);
            Calendar setupCalendar = (Calendar) calendar.clone();
            setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.getFirstDayOfWeek());
            for (int i = 0; i < 7; i++)
                int dayInt = setupCalendar.get(Calendar.DAY_OF_WEEK);
                JLabel label = new JLabel();
                label.setHorizontalAlignment(JLabel.CENTER);
                label.setForeground(foreground);
                if (dayInt == Calendar.SUNDAY)
                    label.setText("s�n");
                else if (dayInt == Calendar.MONDAY)
                    label.setText("man");
                else if (dayInt == Calendar.TUESDAY)
                    label.setText("tir");
                else if (dayInt == Calendar.WEDNESDAY)
                    label.setText("ons");
                else if (dayInt == Calendar.THURSDAY)
                    label.setText("tor");
                else if (dayInt == Calendar.FRIDAY)
                    label.setText("fre");
                else if (dayInt == Calendar.SATURDAY)
                    label.setText("l�r");
                //                days.add(label);
                setupCalendar.roll(Calendar.DAY_OF_WEEK, true);
            setupCalendar = (Calendar) calendar.clone();
            setupCalendar.set(Calendar.DAY_OF_MONTH, 1);
            int first = setupCalendar.get(Calendar.DAY_OF_WEEK);
            for (int i = 0; i < (first-2) ; i++)
                days.add(new JLabel(""));
            for (int i = 1; i <= setupCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); i++)
                final int day = i;
                final JLabel label = new JLabel(String.valueOf(day));
                label.setHorizontalAlignment(JLabel.CENTER);
                label.setForeground(foreground);
                label.addMouseListener(new MouseAdapter()
                    public void mouseReleased(MouseEvent e)
                        label.setOpaque(false);
                        label.setBackground(background);
                        label.setForeground(foreground);
                        calendar.set(Calendar.DAY_OF_MONTH, day);
                        hide();
                        comboBox.requestFocus();
                        if (tabel.isEditing())
                            tabel.getCellEditor(tabel.getEditingRow(),
                            tabel.getEditingColumn()).stopCellEditing();
                        model.setValueAt(dateFormat.format(calendar.getTime()),raekke,1);
                        tabel.requestFocus();
                    public void mouseEntered(MouseEvent e)
                        label.setOpaque(true);
                        label.setBackground(selectedBackground);
                        label.setForeground(selectedForeground);
                    public void mouseExited(MouseEvent e)
                        label.setOpaque(false);
                        label.setBackground(background);
                        label.setForeground(foreground);
                days.add(label);
            popup.add(BorderLayout.CENTER, days);
            popup.pack();
        private JComboBox comboBox;
        private Calendar calendar;
        private JPopupMenu popup;
        private JLabel monthLabel;
        private JPanel days = null;
        private SimpleDateFormat monthFormat = new SimpleDateFormat("MMM yyyy");
        //        private int antaldage=1;
        private Color selectedBackground;
        private Color selectedForeground;
        private Color background;
        private Color foreground;
    private SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    private int raekke=-1;
    private DefaultTableModel model;
    private JTable tabel;
}

come on help plz....

Similar Messages

  • Flex beta 2 - ComboBox not working

    it seems like ComboBoxes are not working with sdk 4.0.0.10485; while they were with 4.0.0.7219
    i simply click and nothing happens..
    code is this:
        <mx:ComboBox>
            <mx:ArrayCollection>
                <fx:String>AK</fx:String>
                <fx:String>AL</fx:String>
                <fx:String>AR</fx:String>
            </mx:ArrayCollection>       
        </mx:ComboBox>
    but also using other kind of dataProviders it's the same..
    am i mistaken?
    Thanks!

    ok, round 10,
    this last round triggered my memory about a caching issue in lists that was resolved about 2 months ago its starting to smell a little like that so I need to do a search in jira and see if it is the same thing. In the mean time this is using the spark component, see if it gets closer to what you are chasing.
    (it only works for item 1 and item 2 - i'm lazy )
    David.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" creationComplete="appInit()">
    <fx:Script>
    <![CDATA[
    import spark.events.IndexChangeEvent;
    import mx.collections.ArrayCollection;
    [Bindable] private var myStates:ArrayCollection= new ArrayCollection([
    {Key:1,state:'ACT',name:'Australian Capital Territory'},
    {Key:2,state:'NSW',name:'New South Wales'},
    {Key:3,state:'NT',name:'Northern Territory'},
    {Key:4,state:'QLD',name:'Queensland'},
    {Key:5,state:'SA',name:'South Australia'},
    {Key:6,state:'TAS',name:'Tasmania'},
    {Key:6,state:'WA',name:'Western Australia'},
    {Key:7,state:'VIC',name:'Victoria'}]);
    [Bindable] private var myACT:ArrayCollection= new ArrayCollection([
    {Key:1,state:'ACT',name:'Kingston'},
    {Key:2,state:'ACT',name:'Manuka'},
    {Key:3,state:'ACT',name:'Narrabundah'},
    {Key:4,state:'ACT',name:'RedHill'}]);
    [Bindable] private var myNSW:ArrayCollection= new ArrayCollection([
    {Key:1,state:'NSW',name:'Cronulla'},
    {Key:2,state:'NSW',name:'Gymea'},
    {Key:3,state:'NSW',name:'Miranda'},
    {Key:4,state:'NSW',name:'Yowie Bay'}]);
    [Bindable] private var myInfo:ArrayCollection= new ArrayCollection();
    private function appInit(): void
    myInfo=myACT;
    protected function cb1_changeHandler(event:IndexChangeEvent):void
    switch(cb1.selectedIndex)
    case 0: myInfo=myACT;
    break;
    case 1: myInfo=myNSW;
    break;
    cb2.selectedIndex=-1;
    ]]>
    </fx:Script>
    <s:DropDownList id="cb1" x="37" y="97" dataProvider="{myStates}" change="cb1_changeHandler(event)" labelField="name" width="180" prompt="select something" enabled="true" selectedIndex="-1"></s:DropDownList>
    <s:DropDownList id="cb2" x="249" y="97" labelField="name" width="180" dataProvider="{myInfo}" prompt="select something" selectedIndex="-1" enabled="true"></s:DropDownList>
    </s:Application>

  • KeyListener not working properly on XP?

    Hi,
    it seems as if the KeyListener and KeyEvent would not work properly on my system. When a KeyEvent is dispatched, the application indicates that the key is "unknown", and the keycode is always zero, no matter which key is pressed - the application cannot make out a difference between the keys.
    I tried it out on another system, uswing XP, too, it does not work either. Is it a bug?
    Peter

    I know I tried out a beta vesion of 1.4 and I wasn't able to listen to any key events. Try searching the bug database, it sounds like a bug to me. Plus I think MS does its best to kill Java.

  • Combobox not working using pdk 2.0

    Hello,
    I had developed iViews using pdk 1.0. I just installed pdk 2.0 and now my comboboxes do not work.  Am I missing something?
    thanks,
    David

    As well as updating your web.xml to 2.4, you need to update the URI so that you use JSTL1.1 instead of JSTL1.0
    If you are using JSP2.0 you should use JSTL1.1
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>[read this post reply #6 for more information|http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0]

  • KeyListener is not working with editable JComboBox??!!!

    When I make the JComboBox editable property to true, the keylistener of the jcombobox is not working why?
    How can I solve this problem?
    Please help
    Haroon

    When editable, focus is placed on the editor component of the combo box. So you need to add the KeyListener to the editior component.
    comboBox.getEditor().getEditerComponent().addKeyListener(...);

  • Adobe Reader XI and Adobe Reader X Pro (Editable PDF Combobox Search is not working properly.)

    I have created Editable PDF using itext(5.3.0) in java. I have used Adobe Reader XI and Adobe Reader X Pro.  But in editable PDF combobox search is  not working properly.
    It's only search first character.

    My (admittedly old and slow) system did this too the first time I opened Reader 11, but it "unfroze" after about fifteen seconds, (an eternity in computing time, I know, but it did eventually open all the way) What you're seeing on the right is the "Tools" panel initializing. That's exactly where mine would freeze up on starting. Once it did finally open fully, I clicked the "Tools" link at the top to close the panel, and I opened and viewed a document that way, then closed reader. Now when I open Reader, the Tools panel doesn't initialize and it opens immediately.
    Reboot and before you open anything else, open Reader. When you open it, DO NOT try to do anything with it until it fully opens, don't click anything, don't try to switch to another app. Give it time to open fully, and then click the Tools link to close it. Then, open and view a document, and close it. Close Reader and reopen it. the Tools panel should remain closed and Reader should open fully immediately.

  • ComboBox not working correctly

    Hi there,
    I am developing a small Flash (AS2) application, using Flash
    CS3, and have run into a problem with the ComboBox componet.
    I am loading another movie into the main movie with the
    following code:
    var container = _level0.createEmptyMovieClip("ui_slider",
    _level0.getNextHighestDepth());
    trace("On last frame");
    container.loadMovie("ui-sliderv2.swf");
    ui_slider._x = 60;
    ui_slider._y = -382
    everything works fine, but none of the comboBoxes are
    working. I can see the first item that can be selected, but the
    pull-down selection is not working. Nothing happens when I click
    it.
    the ui-sliderv2.swf movie works as expected when run on its
    own.
    Here are the links to the SWF.
    http://www.rmp-consulting.com/chomonicx/Chomonicx.html
    The menu SWF on it's own:
    http://www.rmp-consulting.com/chomonicx/ui-sliderv2.html
    Any suggestions?

    apply _lockroot = true to the movie clip that the SWF is
    loaded into.

  • KeyListener not working in Linux

    Hello guys, I'm having a weird problem I was hoping I could get resolved.
    I finished a Pong applet for my Java class, and it works just fine under Windows and on my Mac.
    But when I run it under Linux, the Applet doesn't work correctly.
    The applet draws, and my timer works, but my KeyListener does not work.
    I believe all of my Java files are updated properly.
    But I do not understand why KeyListener does not work under Linux, but it does in Windows.
    I then made a very basic applet just to test my KeyListener, and it still does not work.
    This is how I was taught to do KeyListeners, but if I'm doing something wrong, please help me out!
    here is the basic program code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test extends JApplet implements KeyListener
    int x = 0;
    int y = 250;
    public void init()
    addKeyListener(this);
    public void paint(Graphics g)
    g.setColor(Color.white);
    g.fillRect(0,0,500,500);
    g.setColor(Color.black);
    g.fillRect(x,y,50,50);
    public void keyPressed(KeyEvent event)
    int keyCode = event.getKeyCode();
    if(keyCode == KeyEvent.VK_RIGHT)
    x += 10;
    public void keyReleased(KeyEvent event)
    public void keyTyped(KeyEvent event)

    What if don't use a KeyListener but instead use key binding? For instance,
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    @SuppressWarnings("serial")
    public class Test2 extends JPanel {
      private static final int DELTA_X = 10;
      private static final int DELTA_Y = DELTA_X;
      private static final Dimension MAIN_SIZE = new Dimension(600, 600);
      enum Arrows {
        LEFT(KeyEvent.VK_LEFT, -DELTA_X, 0),
        RIGHT(KeyEvent.VK_RIGHT, DELTA_X, 0),
        UP(KeyEvent.VK_UP, 0, -DELTA_Y),
        DOWN(KeyEvent.VK_DOWN, 0, DELTA_Y);
        private int keyCode;
        private int deltaX, deltaY;
        private Arrows(int keyCode, int deltaX, int deltaY) {
          this.keyCode = keyCode;
          this.deltaX = deltaX;
          this.deltaY = deltaY;
        public int getDeltaX() {
          return deltaX;
        public int getDeltaY() {
          return deltaY;
        public int getKeyCode() {
          return keyCode;
      int x = 0;
      int y = 250;
      public Test2() {
        setBackground(Color.white);
        setPreferredSize(MAIN_SIZE);
        InputMap inMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        ActionMap actMap = getActionMap();
        for (Arrows arrow : Arrows.values()) {
          inMap.put(KeyStroke.getKeyStroke(arrow.getKeyCode(), 0), arrow);
          actMap.put(arrow, new MyAction(arrow));
      private class MyAction extends AbstractAction {
        private Arrows arrow;
        public MyAction(Arrows arrow) {
          this.arrow = arrow;
        public void actionPerformed(ActionEvent e) {
          x += arrow.getDeltaX();
          y += arrow.getDeltaY();
          repaint();
      @Override
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.black);
        g.fillRect(x, y, 50, 50);
    import javax.swing.JApplet;
    @SuppressWarnings("serial")
    public class TestApplet extends JApplet {
      public void init() {
        try {
          javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
              createGUI();
        } catch (Exception e) {
          System.err.println("createGUI didn't successfully complete");
      private void createGUI() {
        getContentPane().add(new Test2());
    }

  • Tab not working properly for Datagrid ItemEditor ComboBox

    When you run the app type a1 in the find an App combo box then hit the tab key.
    Click in the 3rd row in the As Bs column and a combobox will show.
    Type a3 and then hit enter.  Notice that A3 is saved as the selected item and saved to the dataprovider
    Hit the backspace key and hit enter.  Notice that the  null is saved and nothing is selected.
    Type a3 again and hit enter.
    Hit the backspce again but this time hit the tab key.  Notice the previous value is back.  ooops.
    {Code}
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:vo="valueObjects.*"
                   width="100%" height="100%">
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;
                protected function aCBLabel(item:Object):String
                    if (item != null)
                        return item.name;
                    else
                        return "";
                protected function bDG_creationCompleteHandler(event:FlexEvent):void
                    bDG.selectedIndex = 0;
                protected function bAFormat(item:Object, column:DataGridColumn):String
                    if (item [column.dataField] != null)
                        return item [column.dataField].name;
                    else
                        return "";
            ]]>
        </fx:Script>
        <fx:Declarations>
            <vo:ADto id="aDto"/>
            <vo:BDto id="bDto"/>
            <s:ArrayCollection id="aList">
                <vo:ADto>
                    <vo:id>1</vo:id>
                    <vo:name>a1</vo:name>
                    <vo:bs>
                        <vo:BDto>
                            <vo:id>1</vo:id>
                            <vo:aDto>
                                <vo:ADto>
                                    <vo:id>1</vo:id>
                                    <vo:name>a1</vo:name>
                                </vo:ADto>
                            </vo:aDto>
                        </vo:BDto>
                        <vo:BDto>
                            <vo:id>2</vo:id>
                            <vo:aDto>
                                <vo:ADto>
                                    <vo:id>2</vo:id>
                                    <vo:name>a2</vo:name>
                                </vo:ADto>
                            </vo:aDto>
                        </vo:BDto>
                        <vo:BDto>
                            <vo:id>0</vo:id>
                        </vo:BDto>
                    </vo:bs>
                </vo:ADto>
                <vo:ADto>
                    <vo:id>2</vo:id>
                    <vo:name>a2</vo:name>
                    <vo:bs>
                        <vo:BDto>
                            <vo:id>3</vo:id>
                            <vo:aDto>
                                <vo:ADto>
                                    <vo:id>3</vo:id>
                                    <vo:name>a3</vo:name>
                                </vo:ADto>
                            </vo:aDto>
                        </vo:BDto>
                        <vo:BDto>
                            <vo:id>0</vo:id>
                        </vo:BDto>
                    </vo:bs>
                </vo:ADto>
            </s:ArrayCollection>
            <s:ArrayCollection id="bAList">
                <vo:ADto>
                    <vo:id>1</vo:id>
                    <vo:name>a1</vo:name>
                </vo:ADto>
                <vo:ADto>
                    <vo:id>2</vo:id>
                    <vo:name>a2</vo:name>
                </vo:ADto>
                <vo:ADto>
                    <vo:id>3</vo:id>
                    <vo:name>a3</vo:name>
                </vo:ADto>
            </s:ArrayCollection>
        </fx:Declarations>
        <fx:Binding source="aCB.selectedItem as ADto" destination="aDto"/>
        <s:Form id="AForm" width="700" height="170">
            <s:layout>
                <s:BasicLayout/>
            </s:layout>
            <s:HGroup x="0" y="50" width="670" height="60">
                <s:Label height="25" fontWeight="bold" text="Find an A" verticalAlign="middle"/>
                <s:ComboBox id='aCB'
                            prompt="Enter or Select an A Name"
                            labelFunction="aCBLabel"
                            x="110" y="10" width="375">
                    <mx:ArrayCollection id="asList" list="{aList}"/>
                </s:ComboBox>
            </s:HGroup>
        </s:Form>
        <mx:DataGrid id="bDG" x="10" y="140" width="450" height="200"
                     editable="true"
                     dataProvider="{aDto.bs}"
                     creationComplete="bDG_creationCompleteHandler(event)">
            <mx:columns>
                <mx:DataGridColumn id="bidDC"
                                   headerText="id"
                                   editable="true"
                                   dataField="id"
                                   editorDataField="value"
                                   width="50"/>
                <mx:DataGridColumn id="bNameDC"
                                   headerText="As Bs"
                                   editable="true"
                                   dataField="aDto"
                                   labelFunction="bAFormat"
                                   editorDataField="value"
                                   width="150">
                    <mx:itemEditor>
                        <fx:Component>
                            <s:MXDataGridItemRenderer implements="mx.managers.IFocusManagerComponent">
                                <fx:Script>
                                    <![CDATA[
                                        import mx.collections.ArrayCollection;
                                        import mx.controls.dataGridClasses.DataGridListData;
                                        import mx.controls.listClasses.BaseListData;
                                        import mx.events.FlexEvent;
                                        import spark.events.DropDownEvent;
                                        import spark.events.IndexChangeEvent;
                                        [Bindable]
                                        public var bAs:ArrayCollection;
                                        protected function cb_InitializeHandler(event:FlexEvent):void
                                            bAs = outerDocument.bAList;
                                            aDto = outerDocument.bDG.selectedItem.aDto;
                                            if (aDto != null)
                                                var t:ADto;
                                                for (var i:int = 0; i<bAs.length; i++)
                                                    t = bAs[i];
                                                    if (aDto.id == t.id)
                                                        cb.selectedIndex = i;
                                                        break;
                                        override public function setFocus():void
                                            cb.setFocus();
                                        public function get value():ADto
                                            if (cb.isDropDownOpen)
                                                cb.closeDropDown(true);
                                            cb.validateNow();
                                            aDto = cb.selectedItem as ADto;
                                            return aDto
                                        protected function cb_closeHandler(event:DropDownEvent):void
                                            aDto = cb.selectedItem as ADto;
                                    ]]>
                                </fx:Script>
                                <fx:Declarations>
                                    <vo:ADto id="aDto"/>
                                    <!-- Place non-visual elements (e.g., services, value objects) here -->
                                </fx:Declarations>
                                <s:ComboBox id="cb"
                                                width = "100%"
                                                prompt="{aDto.name}"
                                                dataProvider="{bAs}"
                                                labelField="name"
                                                initialize="cb_InitializeHandler(event)"
                                                close="cb_closeHandler(event)">
                                </s:ComboBox>
                            </s:MXDataGridItemRenderer>
                        </fx:Component>
                    </mx:itemEditor>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>
    </s:Application>
    {Code}
    {Code}
    package valueObjects
        import com.adobe.fiber.services.IFiberManagingService;
        import com.adobe.fiber.valueobjects.IValueObject;
        import mx.collections.ArrayCollection;
        import valueObjects.BDto;
        import com.adobe.fiber.core.model_internal;
        use namespace model_internal;
        public class ADto implements com.adobe.fiber.valueobjects.IValueObject
            private var _internal_id : int;
            private var _internal_name : String;
            private var _internal_bs : ArrayCollection;
            model_internal var _internal_bs_leaf:valueObjects.BDto;
            public function ADto()
            public function get id() : int
                return _internal_id;
            public function get name() : String
                return _internal_name;
            public function get bs() : ArrayCollection
                return _internal_bs;
            public function set id(value:int) : void
                var oldValue:int = _internal_id;
                if (oldValue !== value)
                    _internal_id = value;
            public function set name(value:String) : void
                var oldValue:String = _internal_name;
                if (oldValue !== value)
                    _internal_name = value;
            public function set bs(value:*) : void
                var oldValue:ArrayCollection = _internal_bs;
                if (oldValue !== value)
                    if (value is ArrayCollection)
                        _internal_bs = value;
                    else if (value is Array)
                        _internal_bs = new ArrayCollection(value);
                    else if (value == null)
                        _internal_bs = null;
                    else
                        throw new Error("value of bs must be a collection");
            private var _managingService:com.adobe.fiber.services.IFiberManagingService;
            public function set managingService(managingService:com.adobe.fiber.services.IFiberManagi ngService):void
                _managingService = managingService;
    {Code}
    {Code}
    package valueObjects
    import com.adobe.fiber.core.model_internal;
    import com.adobe.fiber.services.IFiberManagingService;
    import com.adobe.fiber.valueobjects.IValueObject;
    import valueObjects.ADto;
    import mx.collections.ArrayCollection;
    use namespace model_internal;
    public class BDto implements com.adobe.fiber.valueobjects.IValueObject
        private var _internal_id : int;
        private var _internal_aDto : ADto;
        private static var emptyArray:Array = new Array();
        public function BDto()
            _internal_id = 0;
        public function get id() : int
            return _internal_id;
        public function get aDto() : ADto
            return _internal_aDto;
        public function set id(value:int) : void
            var oldValue:int = _internal_id;
            if (oldValue !== value)
                _internal_id = value;
        public function set aDto(value:ADto) : void
            var oldValue:ADto = _internal_aDto;
            if (oldValue !== value)
                _internal_aDto = value;
        private var _managingService:com.adobe.fiber.services.IFiberManagingService;
        public function set managingService(managingService:com.adobe.fiber.services.IFiberManagi ngService):void
            _managingService = managingService;
    {Code}

    the reason the tab was not working is because it was not changing the selection and just exiting the combo box.  So, in the value function add if (cb.textInput.text == "") cb.selectedIndex = -1;  This will change the selection as desired and fixes the problem.

  • 6300 & Lotus Notes - Calander Alert Not Working

    Hi I have an O2 6300 & Lotus Notes ( v6 )and the phones calander alert not working / going off when it should.
    I've not changed any thing that I am aware of from the defaults and its less than a week or two old so I'm hoping its not a software OS bug and a user issue / some thing I have to switch on some where.
    Can any one help me ?
    Terran
    ( PS I noticed some N95 users had the same prob last year )

    Hi SaikatDas,
    Thank you for posting in MSDN forum.
    Since this forum is to discuss: Visual Studio WPF/SL Designer, Visual Studio Guidance Automation
    Toolkit, Developer Documentation and Help System, and Visual Studio Editor.
    Based on your issue, it is related to the IIS, so I’m afraid that it is not the correct forum for this issue. therefore, I suggest you can post this issue directly to the IIS forum:http://forums.iis.net/
    , maybe you will get better support.
    Thanks for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • When my thread starts running, at that time keylistener is not working.

    when my thread starts running, at that time keylistener is not working.
    plz reply me.

    //FrameShow.java
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import java.awt.Dimension;
    import java.awt.geom.Dimension2D;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.util.logging.Level;
    import java.awt.event.*;
    import java.util.*;
    public class FrameShow extends JFrame implements ActionListener,KeyListener
         boolean paused=false;
         JButton stop;
         JButton start;
         JButton exit;
         public IncludePanel CenterPanel;
         public FrameShow()
    CenterPanel= new IncludePanel();
              Functions fn=new Functions();
              int height=fn.getScreenHeight();
              int width=fn.getScreenWidth();
              setTitle("Game Assignment--Santanu Tripathy--MCA");
              setSize(width,height);
              setResizable(false);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              show();
              initComponents();
              DefaultColorSet();
              this.addKeyListener(this);
         this.setFocusable(true);
         public void initComponents()
              Container contentpane=getContentPane();
              //Creating Panel For Different Side
              JPanel EastPanel= new JPanel();
              JPanel WestPanel= new JPanel();
              JPanel NorthPanel= new JPanel();
              JPanel SouthPanel= new JPanel();
              //CenterPanel = new IncludePanel();
              //IncludePanel CenterPanel= new IncludePanel();
              EastPanel.setPreferredSize(new Dimension(100,10));
              WestPanel.setPreferredSize(new Dimension(100,10));
              NorthPanel.setPreferredSize(new Dimension(10,100));
              SouthPanel.setPreferredSize(new Dimension(10,100));
              //CenterPanel.setPreferredSize(new Dimension(200,200));
              //Adding Color to the Panels
              NorthPanel.setBackground(Color.green);
              SouthPanel.setBackground(Color.orange);
              CenterPanel.setBackground(Color.black);
              //Creating Border For Different Side
              Border EastBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border WestBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border NorthBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border SouthBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border CenterBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              //Creating Components For East Panel
              JLabel left= new JLabel("LEFT");
              JLabel right= new JLabel("RIGHT");
              JLabel rotate= new JLabel("ROTATE");
              left.setForeground(Color.blue);
              right.setForeground(Color.blue);
              rotate.setForeground(Color.blue);
              //Creating Components For West Panel
              ButtonGroup group = new ButtonGroup();
              JRadioButton rb1 = new JRadioButton("Pink",false);
              JRadioButton rb2 = new JRadioButton("Cyan",false);
              JRadioButton rb3 = new JRadioButton("Orange",false);
              JRadioButton _default = new JRadioButton("Black",true);
              rb1.setForeground(Color.pink);
              rb2.setForeground(Color.cyan);
              rb3.setForeground(Color.orange);
              _default.setForeground(Color.black);
              //Creating Components For North Panel
              JLabel name= new JLabel("Santanu Tripathy");
              name.setForeground(Color.blue);
              name.setFont(new Font("Serif",Font.BOLD,30));
              //Creating Components For South Panel
              start = new JButton();
              stop = new JButton();
              exit = new JButton();
              start.setToolTipText("Click this button to start the game");
              start.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              start.setText("START");
              start.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              start.setMaximumSize(new java.awt.Dimension(90, 35));
              start.setMinimumSize(new java.awt.Dimension(90, 35));
              start.setPreferredSize(new java.awt.Dimension(95, 35));
              if(paused)
                   stop.setToolTipText("Click this button to pause the game");
              else
                   stop.setToolTipText("Click this button to resume the game");
              stop.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              stop.setText("PAUSE");
              stop.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              stop.setMaximumSize(new java.awt.Dimension(90, 35));
              stop.setMinimumSize(new java.awt.Dimension(90, 35));
              stop.setPreferredSize(new java.awt.Dimension(95, 35));
              exit.setToolTipText("Click this button to exit from the game");
              exit.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              exit.setText("EXIT");
              exit.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              exit.setMaximumSize(new java.awt.Dimension(90, 35));
              exit.setMinimumSize(new java.awt.Dimension(90, 35));
              exit.setPreferredSize(new java.awt.Dimension(95, 35));
              //Adding some extra things to the Panels
              group.add(rb1);
              group.add(rb2);
              group.add(rb3);
              group.add(_default);
              //Adding Component into the Panels
              EastPanel.add(left);
              EastPanel.add(right);
              EastPanel.add(rotate);
              WestPanel.add(rb1);
              WestPanel.add(rb2);
              WestPanel.add(rb3);
              WestPanel.add(_default);
              NorthPanel.add(name);
              SouthPanel.add(start);
              SouthPanel.add(stop);
              SouthPanel.add(exit);
              //Adding Border Into the Panels
              EastPanel.setBorder(EastBr);
              WestPanel.setBorder(WestBr);
              NorthPanel.setBorder(NorthBr);
              SouthPanel.setBorder(SouthBr);
              CenterPanel.setBorder(CenterBr);
              //Adding Panels into the Container
              EastPanel.setLayout(new GridLayout(0,1));
              contentpane.add(EastPanel,BorderLayout.EAST);
              WestPanel.setLayout(new GridLayout(0,1));
              contentpane.add(WestPanel,BorderLayout.WEST);
              contentpane.add(NorthPanel,BorderLayout.NORTH);
              contentpane.add(SouthPanel,BorderLayout.SOUTH);
              contentpane.add(CenterPanel,BorderLayout.CENTER);
              //Adding Action Listeners
              rb1.addActionListener(this);
              rb2.addActionListener(this);
              rb3.addActionListener(this);
              _default.addActionListener(this);
              exit.addActionListener(this);
              start.addActionListener(this);
    try
              start.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
                        start.setEnabled(false);
    CenterPanel.drawCircle();
    catch(Exception e)
    {System.out.println("Exception is attached with sart button exp = "+e);}
    try
              stop.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
                        paused=!paused;
                        if(paused)
                             start.setToolTipText("Click this button to resume the game");
                             stop.setText("RESUME");
                        else
                             start.setToolTipText("Click this button to pause the game");
                             stop.setText("PAUSE");
    CenterPanel.pause();
    catch(Exception e)
    {System.out.println("Exception is attached with sart button exp = "+e);}
         public void DefaultColorSet()
              getContentPane().setBackground(Color.white);
         public void actionPerformed(ActionEvent AE)
              String str=(String)AE.getActionCommand();
              if(str.equalsIgnoreCase("pink"))
                   CenterPanel.setBackground(Color.pink);
              if(str.equalsIgnoreCase("cyan"))
                   CenterPanel.setBackground(Color.cyan);
              if(str.equalsIgnoreCase("orange"))
                   CenterPanel.setBackground(Color.orange);
              if(str.equalsIgnoreCase("black"))
                   CenterPanel.setBackground(Color.black);
              if(str.equalsIgnoreCase("exit"))
                   System.exit(0);
         public void keyTyped(KeyEvent kevt)
    //repaint();
    public void keyPressed(KeyEvent e)
              System.out.println("here key pressed");
              //CenterPanel.dec();
         public void keyReleased(KeyEvent ke) {}
    }//End of FrameShow.ja
    //IncludePanel.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.Graphics.*;
    import java.awt.Dimension;
    import java.awt.geom.Dimension2D;
    import java.util.*;
    import java.util.logging.Level;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class IncludePanel extends JPanel implements Runnable
    int x=0,y=0;
    int color_1=0;
    int color_2=1;
    int start=0;
    Thread th;
    Image red,blue,green,yellow;
    java.util.List image;
    static boolean PAUSE=false;
         public IncludePanel()
         red= Toolkit.getDefaultToolkit().getImage("red.png");
         blue= Toolkit.getDefaultToolkit().getImage("blue.png");
         green= Toolkit.getDefaultToolkit().getImage("green.png");
         yellow= Toolkit.getDefaultToolkit().getImage("yellow.png");
    public void paintComponent(Graphics g)
              super.paintComponent(g);
              draw(g);
    public void dec()
         System.out.println("in dec method");
         x=x+30;
    public void draw(Graphics g)
              g.setColor(Color.red);
              int xx=0,yy=0;
              for (int row=0;row<=12;row++)
                   g.drawLine(xx,yy,180,yy);
                   yy=yy+30;
              xx=0;
              yy=0;
              for (int col=0;col<=6;col++)
                   g.drawLine(xx,yy,xx,360);
                   xx=xx+30;
              if(color_1==0)
                   g.drawImage(red, x, y, this);
              else if(color_1==1)
                   g.drawImage(blue,x, y, this);
              else if(color_1==2)
                   g.drawImage(green,x,y, this);
              else if(color_1==3)
                   g.drawImage(yellow,x,y, this);
    x=x+30;
              if(color_2==0)
                   g.drawImage(red, x, y, this);
              else if(color_2==1)
                   g.drawImage(blue,x,y, this);
              else if(color_2==2)
                   g.drawImage(green,x,y, this);
              else if(color_2==3)
                   g.drawImage(yellow,x,y, this);
    x=0;
    public void drawCircle( )
         th=new Thread(this);
         th.start();
         public void pause()
              if(PAUSE)
                   th.resume();
                   PAUSE=false;
                   return;
              if(!PAUSE)
              PAUSE=true;
         public synchronized void run()
              Random rand = new Random();
              Thread ani=Thread.currentThread();
              while(ani==th)
                   if(PAUSE)
                        th.suspend();
                   if(y==330)
                        color_1 = Math.abs(rand.nextInt())%4;
                        color_2 = Math.abs(rand.nextInt())%4;
                        if(color_1==color_2)
                             color_2=(color_2+1)%4;
                        y=0;
                   else
                        y=y+30;
                   repaint();
                   try
                        Thread.sleep(700);
                   catch(Exception e)
         }//End of run
    i sent two entire program

  • Ctrl+tab is not working in editing mode

    I have JcheckBox and JTable in my JPanel. When user clicks or presses F2 to edit any cell value of the JTable a comboBox will appear with possible values. (This comboBox is coming from table CellEditor). When user presses ctrl+tab from the table focus should transfer to JComboBox all time. It is working only when the user presses ctrl+tab from the table cell which is not in editing mode. If the user presses ctrl+tab from the table cell which is in editing mode (i.e. focus is on the ComboBox of the cellEditor) it does not work. Please help me to find the solution.
    I give a sample code here for your reference.
    public class Frame1 extends JFrame {
    public Frame1()
    super();
    this.setLayout( null );
    this.setSize( new Dimension(400, 300) );
    JTextField ch = new JTextField();
    ch.setVisible(true);
    ch.setBounds(10, 10, 10, 10);
    this.add(ch, null);
    DefaultTableModel tmodel = new DefaultTableModel(3, 1);
    tmodel.setValueAt("0 0 1",0,0);
    tmodel.setValueAt("1 0 1",1,0);
    tmodel.setValueAt("2 0 1",2,0);
    JTable custLayersTable = new JTable(tmodel);
    custLayersTable.getColumnModel().getColumn(0).
    setCellEditor(new ComboEditor());
    custLayersTable.setBounds(new Rectangle(40, 40, 280, 145));
    custLayersTable.setSurrendersFocusOnKeystroke(true);
    this.add(custLayersTable, null);
    public static void main(String[] args)
    Frame1 a = new Frame1();
    a.setVisible(true);
    final class ComboEditor extends AbstractCellEditor
    implements TableCellEditor
    public Component getTableCellEditorComponent(JTable table,
    Object value,
    boolean isSelected,
    int row,
    int column)
    Vector<String> layerValSet = new Vector<String>();
    for(int i=0; i<3; i++)
    layerValSet.add(row+" "+column+" "+i);
    mComboModel = new DefaultComboBoxModel(layerValSet);
    mComboModel.setSelectedItem(value);
    mEditorComp = new JComboBox(mComboModel);
    return mEditorComp;
    public Object getCellEditorValue()
    return mEditorComp.getSelectedItem();
    private DefaultComboBoxModel mComboModel;
    private JComboBox mEditorComp;
    }

    Thanks a lot for your reply.
    Since the textField is in a different class i could not use the transferFocus API directly. I tried the following code in the keyreleased event of Combo Box but it was not working.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(
    e.getComponent().getParent());
    I also tried the following code in stopCellEditing and is not working.
    KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent();
    Is there any other way to achieve this?

  • DataTrigger is not working in xaml wpf

    Hi All,
    I want to change the Data templates dynamically based on some selection. Here I have used DataTrigger to which I have binded a property which is not working. I don't know why its not working.
    Please find below .xaml code -                                
            <DataTemplate x:Key="StackTemplate">
                <TextBlock x:Name="txtStack" Text="We are using Stack Panel"></TextBlock>
            </DataTemplate>
            <DataTemplate x:Key="DockTemplate">
                <TextBlock x:Name="txtDock" Text="We are using Dock Panel"></TextBlock>
            </DataTemplate>
            <DataTemplate x:Key="WrapTemplate">
                <TextBlock x:Name="txtWrap" Text="We are using Wrap Panel"></TextBlock>
            </DataTemplate>
            <DataTemplate x:Key="CanvasTemplate">
                <TextBlock x:Name="txtcanvas" Text="we are using Canvas panel"></TextBlock>
            </DataTemplate>
        </Window.Resources>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="50"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="170"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Grid.Row="0" x:Name="Txtblk" Text="Choose Layout Panel"></TextBlock>
            <ComboBox Grid.Column="1" Width="200"  ItemsSource="{Binding Source={StaticResource LoadCombo}}" Margin="66,12,66,0"></ComboBox> // loaded from xaml
            <ItemsControl Grid.Column="1" Grid.Row="1" x:Name="itemctrl" Height="250" Width="280">
                <DataTemplate>
                    <ContentControl Content="{Binding}">
                        <ContentControl.Style>
                            <Style TargetType="{x:Type ContentControl}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=MyProperty,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="0">
                                        <Setter Property="ContentTemplate" Value="{StaticResource StackTemplate}"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=MyProperty,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="1">
                                        <Setter Property="ContentTemplate" Value="{StaticResource DockTemplate}"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=MyProperty,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="2">
                                        <Setter Property="ContentTemplate" Value="{StaticResource WrapTemplate}"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Path=MyProperty,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="3">
                                        <Setter Property="ContentTemplate" Value="{StaticResource CanvasTemplate}"></Setter>
                                    </DataTrigger>                                
                                </Style.Triggers>
                            </Style>
                        </ContentControl.Style>
                    </ContentControl>
                </DataTemplate>
            </ItemsControl>
    Here is my .xaml.cs class - 
      public partial class MainWindow : Window
            public string Select { get; set; }
            public string MyProperty
                get
                    string number=string.Empty;
                    switch (Select)
                        case "STACKPANEL": 
                            number = "0"; break;
                        case "DOCKPANEL":
                            number = "1"; break;
                        case "WRAPPANEL":
                            number = "2"; break;
                        case "CANVAS":
                            number= "3"; break;
                    return number;
            public MainWindow()
                InitializeComponent();
                DataContext = this;
                Select = "0";
                cmb.SelectionChanged += new SelectionChangedEventHandler(cmb_SelectionChanged);
            void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
                Select = (sender as ComboBox).Text;
    Please help me.

    That isn't going to work.
    Selecting datatemplate is a one off process.
    When you're looking at the view, it's done.
    I think if you used a contenttemplateselector you could force the issue:
    MyControl.ContentTemplateSelector =
    new MyDataTemplateSelector();
    I very rarely use those myself though.
    Personally, I would be inclined to just switch out the control for a new one with the appropriate template.
    It's a view responsibility so doing that in code behind isn't even breaking mvvm.
    Your code coverage might dip a little, but this doesn't look like a real app anyhow.
    I agree with Andy, using DataTemplateSelector should be the right direction, please refer to this case to know how it works:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/f7c60968-f3a0-499a-a20e-01aac82d942f/datatemplate-for-generic-type-is-not-working?forum=wpf
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Addin does not work under Windows 2003

    Hello.
    I have a few Excel addins with forms and other objects that work fine on my desktop (Windows XP), where I have OO4O installed. Recently a user needed to start using these addins and I installed OO4O on a server using Windows 2003. The user (Windows XP also) connects to the server using Remote Desktop Connection. However when he uses the addins they do not work. The connection to the database is fine, I know that because otherwise some forms would not appear. The problem is when the user presses the first combobox of each form no data appears. If I enter just some text on that combobox, which enables a second combobox, then this second combobox works fine, I can see the database data. When the form allows me to press a button that runs a query I receive the message “Not all variables bound”.
    If anybody can help I would very much appreciated.
    Tks
    Octavio

    As I wrote, I have tried to reinstall the driver without success.
    It should be a hardware problem if you are able to run the camera perfectly. Are you using a 64- or 32-bit OS?
    Thanks!

  • Mail in Mavericks not working between two macs.

    Hello all
    I have a 2012 iMac as well as a 2009 MacBook Pro. I am running Mavericks on both machines. I'm having issues with my exchange e-mail contacts and calendar, syncing between the two devices. I will get it to work on one device or the other but not both at the same time. More specifically in mail when it is working on one computer and I go to check my mail on the other it asks me to put in my password for that e-mail account. Every time I do this it does not work and it always returns an error. If I go to delete an account on either computer it tells me the account is linked to "Internet account" under settings for the computer. When I delete the exchange account from "Internet account" it warns me that it will delete the account off of both macs. When I re-add the exchange account mail, contacts and calander all work for whichever computer I add it on. But the other computer will only show calander or contacts not all three.
    Does anyone have an idea what might be wrong or have a solution? This is very frustrating and I cant seem to find a solution.

    Hi,
    Those last two I do not have on my iMac that is working and part of the issue I have in testing is I don't have a second Mac that will run Yosemite.
    Realistically it could be any of the ones that contain com.apple.ids.service.com.apple.private.alloy.***.plist
    The plain SMS.plist  only states it has been started up not what the Mac is linked to.
    Unfortunately nothing is standing out as the Specific one for me at the moment.
    9:34 pm      Sunday; December 28, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

Maybe you are looking for