Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Contributor
Posts: 18
Registered: ‎07-24-2013
My Device: BLackberry 10
My Carrier: Mobile Apps developer

BB 10 cascades Lable color change based on lable value

I have a container with the labels like this... But if the Label value is negative i need to Add Red color otherwise Green color. How can i do it in BB 10 cascades in Qml.

 

 Container {
                                        leftPadding: 15.0
                                        rightPadding: 15.0
                                        layout: StackLayout {
                                            orientation: LayoutOrientation.LeftToRight
                                        }
                                        topPadding: 20.0

                                        Label {
                                            id: symbol
                                            text: ListItemData.Symbol_En

                                            // Text Style and size etc
                                            textStyle.base: SystemDefaults.TextStyles.SubtitleText
                                            textStyle.fontSizeValue: 30.0
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 4
                                            }
                                            verticalAlignment: VerticalAlignment.Center
                                            horizontalAlignment: HorizontalAlignment.Center

                                        }
                                        Label {
                                            id: change
                                            text: ListItemData.PerChange
                                            textStyle.base: SystemDefaults.TextStyles.SubtitleText
                                            textStyle.fontSizeValue: 30.0
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 2
                                            }
                                            verticalAlignment: VerticalAlignment.Center
                                            horizontalAlignment: HorizontalAlignment.Center

                                        }
                                        Label {
                                            id: ltp
                                            text: ListItemData.LTP
                                            textStyle.base: SystemDefaults.TextStyles.SubtitleText
                                            textStyle.fontSizeValue: 30.0
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 1
                                            }
                                            verticalAlignment: VerticalAlignment.Center
                                            horizontalAlignment: HorizontalAlignment.Center

                                        }
                                        Label {
                                            id: highValue
                                            text: ListItemData.High
                                            textStyle.base: SystemDefaults.TextStyles.SubtitleText
                                            textStyle.fontSizeValue: 30.0
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 1
                                            }
                                            verticalAlignment: VerticalAlignment.Center
                                            horizontalAlignment: HorizontalAlignment.Center

                                        }
                                        Label {
                                            id: lowValue
                                            text: ListItemData.Low
                                            textStyle.base: SystemDefaults.TextStyles.SubtitleText
                                            textStyle.fontSizeValue: 30.0
                                            layoutProperties: StackLayoutProperties {
                                                spaceQuota: 1
                                            }
                                            verticalAlignment: VerticalAlignment.Center
                                            horizontalAlignment: HorizontalAlignment.Center

                                        }

 Any Help is Appropriated, Thanks !!!

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: BB 10 cascades Lable color change based on lable value

You are in the wrong forum, I've asked a moderator to switch it to the developer native forum.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: BB 10 cascades Lable color change based on lable value

You can change a background colour using the background property.

 

background:  value < 0 ? Color.Red : Color.Green


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.