Click here to Skip to main content
15,899,124 members
Home / Discussions / WPF
   

WPF

 
QuestionCould you take a look and give me some suggestions? Pin
Michael Sync3-Jul-08 5:59
Michael Sync3-Jul-08 5:59 
QuestionSystem.Drawing.Color to System.Windows.Media.Brush Pin
KBou3-Jul-08 3:43
KBou3-Jul-08 3:43 
AnswerRe: System.Drawing.Color to System.Windows.Media.Brush Pin
Pete O'Hanlon3-Jul-08 4:38
mvePete O'Hanlon3-Jul-08 4:38 
QuestionRe: System.Drawing.Color to System.Windows.Media.Brush Pin
KBou3-Jul-08 4:44
KBou3-Jul-08 4:44 
AnswerRe: System.Drawing.Color to System.Windows.Media.Brush Pin
Insincere Dave3-Jul-08 5:19
Insincere Dave3-Jul-08 5:19 
AnswerRe: System.Drawing.Color to System.Windows.Media.Brush Pin
KBou3-Jul-08 5:01
KBou3-Jul-08 5:01 
AnswerRe: System.Drawing.Color to System.Windows.Media.Brush [modified] Pin
appxdev17-Feb-11 15:26
appxdev17-Feb-11 15:26 
QuestionBind color to Rectangle in WPF Pin
ezazazel2-Jul-08 11:06
ezazazel2-Jul-08 11:06 
Hy! I'm trying to bind a given color to a rectangle in WPF... by now without success.
Here's my not working) approach:

XAML:
            <Rectangle Fill="{Binding Path=color1}" 
                       Margin="10,10,10,10" 
                       Height="Auto" Width="Auto"
                       Grid.Column="0" Grid.Row="0"
                       />      
...     


C# Code:
public Window2()
        {
            InitializeComponent();
            bgColors.SetColors(Colors.Green, Colors.Green, Colors.Red, Colors.Red);
            MainDockPanel.DataContext = bgColors;           
        }

and
internal class BGColors : INotifyPropertyChanged
    {
        private Color Color1;
        public Color color1
        {
            get { return Color1; }
            set { Color1 = value;
            NotifyPropertyChanged("color1");
            }
        }

        private Color Color2;
        public Color color2
        {
            get { return Color2; }
            set { Color2 = value;
            NotifyPropertyChanged("color2");
            }
        }

        private Color Color3;
        public Color color3
        {
            get { return Color3; }
            set
            {
                Color1 = value;
                NotifyPropertyChanged("color3");
            }
        }

        private Color Color4;
        public Color color4
        {
            get { return Color4; }
            set
            {
                Color2 = value;
                NotifyPropertyChanged("color4");
            }
        }

        public void SetColors(Color color1, Color color2, Color color3, Color color4)
        {
            this.color1 = color1;
            this.color2 = color2;
            this.color3 = color3;
            this.color4 = color4;
        }

        private void NotifyPropertyChanged(string p)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(p));
            }
        }

        public override string ToString()
        {
            return color1.ToString();
        }
  
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }


Binding the values as string to a label works perfectly, but no Colors can be assigned.
Help would be appreciated.
Thx in advance
AnswerRe: Bind color to Rectangle in WPF Pin
Gideon Engelberth2-Jul-08 11:59
Gideon Engelberth2-Jul-08 11:59 
AnswerRe: Bind color to Rectangle in WPF Pin
User 223706-Jul-08 16:40
User 223706-Jul-08 16:40 
AnswerRe: Bind color to Rectangle in WPF Pin
ezazazel7-Jul-08 6:25
ezazazel7-Jul-08 6:25 
AnswerRe: Bind color to Rectangle in WPF Pin
Sudarsan Srinivasan14-Mar-09 1:45
Sudarsan Srinivasan14-Mar-09 1:45 
QuestionHow can we convert Brushes.* to the hexadecimal numbers in WPF ? Pin
Mohammad Dayyan2-Jul-08 9:49
Mohammad Dayyan2-Jul-08 9:49 
AnswerRe: How can we convert Brushes.* to the hexadecimal numbers in WPF ? Pin
Pete O'Hanlon2-Jul-08 10:06
mvePete O'Hanlon2-Jul-08 10:06 
GeneralRe: How can we convert Brushes.* to the hexadecimal numbers in WPF ? Pin
Mohammad Dayyan2-Jul-08 10:17
Mohammad Dayyan2-Jul-08 10:17 
GeneralRe: How can we convert Brushes.* to the hexadecimal numbers in WPF ? Pin
Pete O'Hanlon2-Jul-08 10:27
mvePete O'Hanlon2-Jul-08 10:27 
GeneralRe: How can we convert Brushes.* to the hexadecimal numbers in WPF ? Pin
Mohammad Dayyan2-Jul-08 10:51
Mohammad Dayyan2-Jul-08 10:51 
QuestionTreeListView Drag and Drop Pin
anci12-Jul-08 1:19
anci12-Jul-08 1:19 
AnswerRe: TreeListView Drag and Drop Pin
Pete O'Hanlon2-Jul-08 3:36
mvePete O'Hanlon2-Jul-08 3:36 
QuestionSet context sensitive help in wpf Pin
Member 46946271-Jul-08 22:22
Member 46946271-Jul-08 22:22 
AnswerRe: Set context sensitive help in wpf Pin
Member 46946271-Jul-08 23:07
Member 46946271-Jul-08 23:07 
QuestionHow can we get richTextbox 's text in WPF ? Pin
Mohammad Dayyan1-Jul-08 19:10
Mohammad Dayyan1-Jul-08 19:10 
AnswerRe: How can we get richTextbox 's text in WPF ? Pin
Member 46946271-Jul-08 22:39
Member 46946271-Jul-08 22:39 
GeneralRe: How can we get richTextbox 's text in WPF ? Pin
Mohammad Dayyan2-Jul-08 2:57
Mohammad Dayyan2-Jul-08 2:57 
QuestionHow can we convert a string to the Brush ? Pin
Mohammad Dayyan1-Jul-08 15:22
Mohammad Dayyan1-Jul-08 15:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.