Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
How to bind a setter property value with a variable in WPF from one window to another?
I have this Code :
<Style x:Key="Style1" TargetType="Button">
<Setter Property="Background" >
                    <SolidColorBrush Color=" COLORHERE "></SolidColorBrush>
I want to bind the color with a variable in another window to change the color for all buttons at runtime. I am coding in VB.NET
<Thanks All="Very Much"> :D
Posted 18-Jan-13 10:31am
Edited 18-Jan-13 11:39am
Sergey Alexandrovich Kryukov at 18-Jan-13 16:42pm
So, is if Forms or WPF?! There are different libraries. You either use one or another. (This is also interop, but I think we don't discuss this pathology only applicable to using some legacy code.) —SA
Abed AlSayed at 18-Jan-13 17:18pm
WPF, it maybe an easy solution for my question, but I am new to WPF, you told me that WPF is faster than winForm on my other account(abdallah alsayed) Here : ( and U were right. My Project (GIF animator) is pretty fast even if the used Picture is larger than 54 MB, My language is not English so I don't really know what words to use in my questions, but I meant that I want to change the "Style1" background Property at runtime using a code, then when the style background changed the buttons background will change too, I'm I wrong? Thanks
Sergey Alexandrovich Kryukov at 18-Jan-13 17:25pm
That's not English, this is just the terminology you need to be aware of. WPF does not have the class named "Form". There is System.Windows.Forms.Form class, but this is a different library. In WPF, you normally use the class "Window" instead of that. The tag "Forms" in your tag is what we use, but in your case please remove it, to avoid further confusions. You are the most interested in that. Other tags are fine. —SA P.S.: I'm sorry, I'm not 100% sure what happens with the child background when you change this style (I would guess not), did not do if for a while. But wouldn't it be easier for you just to find out by trying it? :-)
Abed AlSayed at 18-Jan-13 17:36pm
Sorry I'll be careful the next time I ask. ' But wouldn't it be easier for you just to find out by trying it?' >>> I wouldn't ask if I know what code should I use to edit a setter.value at runtime and try it :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
0 Sergey Alexandrovich Kryukov 472
1 sanket saxena 355
2 CPallini 205
3 thatraja 200
4 OriginalGriff 195
0 Sergey Alexandrovich Kryukov 8,784
1 OriginalGriff 5,025
2 Peter Leow 3,839
3 Maciej Los 3,535
4 Er. Puneet Goel 3,107

Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid