Click here to Skip to main content
15,914,795 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Generate decimal point automatically while entering in textbox in wpf Pin
Christian Graus1-Sep-10 20:06
protectorChristian Graus1-Sep-10 20:06 
AnswerRe: Generate decimal point automatically while entering in textbox in wpf Pin
Abhinav S1-Sep-10 20:47
Abhinav S1-Sep-10 20:47 
GeneralRe: Generate decimal point automatically while entering in textbox in wpf Pin
sumit70341-Sep-10 21:39
sumit70341-Sep-10 21:39 
AnswerRe: Generate decimal point automatically while entering in textbox in wpf Pin
Pete O'Hanlon1-Sep-10 23:07
mvePete O'Hanlon1-Sep-10 23:07 
AnswerRe: Generate decimal point automatically while entering in textbox in wpf Pin
V.2-Sep-10 20:16
professionalV.2-Sep-10 20:16 
GeneralRe: Generate decimal point automatically while entering in textbox in wpf Pin
Pete O'Hanlon2-Sep-10 22:38
mvePete O'Hanlon2-Sep-10 22:38 
GeneralRe: Generate decimal point automatically while entering in textbox in wpf Pin
V.2-Sep-10 22:47
professionalV.2-Sep-10 22:47 
QuestionTrying to bind to a dependency property [modified] Pin
Christian Graus1-Sep-10 19:26
protectorChristian Graus1-Sep-10 19:26 
I have a custom control, called 'YesNoButton'. It's two buttons, one says yes, one says no. I have a property, 'IsYes'. I'd like to bind to that property from my preferences class, so that I don't have to write any code to tie the two. Here's what I have:


<ctl:YesNoButton x:Name="showProgessOnDesktop" IsYes="{Binding Mode=TwoWay, Path=ShowOnDesktop, Source={x:Static c:Preferences.Instance}}"/>


is my XAML with my attempted binding. The code in the control is as follows ( created with help from the tab/tab auto generate thing )


public bool IsYes

{

    get { return (bool)GetValue(IsYesProperty); }

    set

    {

        SetValue(IsYesProperty, value);

        no.Foreground = (value) ? Brushes.LightGray : Brushes.Black;

        yes.Foreground = (value) ? Brushes.Black : Brushes.LightGray;

    }

}



public static readonly DependencyProperty IsYesProperty =

    DependencyProperty.Register("IsYes", typeof(bool), typeof(YesNoButton), new UIPropertyMetadata(false));


This code compiles and runs, so I assume that my binding is where the issue is. Preferences is a static class, with Instance as a static variable. If I set it in code, it works, internally, but does not change the UI on this form. If I set the default of the dependency property to 'true' it doesn't change the UI. If I set breakpoints, my setter is called when the value is set in code, and the values in the preferences class get set. My issue is entirely that I can't get the control to call the right getter on the preferences class to set itself up initially, that is, it always shows the same value and does not respect the value in the prefs class.

OK, I got it. I had to wait for the Loaded event, THEN I had to access the property to force it to read from the source, which then ran the code to set the state of the UI. If there's any way to make it read automatically, I'd love to know it.



Thanks for any help.
Christian Graus

Driven to the arms of OSX by Vista.

Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
modified on Thursday, September 2, 2010 2:04 AM

AnswerRe: Trying to bind to a dependency property Pin
PumbaPumba27-Sep-10 7:53
PumbaPumba27-Sep-10 7:53 
QuestionFinding a Keybinding Pin
Drathmar1-Sep-10 10:36
Drathmar1-Sep-10 10:36 
QuestionAdding custom routed event of user control to xaml of a window in wpf Pin
dashingsidds1-Sep-10 5:04
dashingsidds1-Sep-10 5:04 
AnswerRe: Adding custom routed event of user control to xaml of a window in wpf Pin
dashingsidds1-Sep-10 22:35
dashingsidds1-Sep-10 22:35 
Questionchanging skins Pin
V.1-Sep-10 4:23
professionalV.1-Sep-10 4:23 
AnswerRe: changing skins Pin
Ian Shlasko1-Sep-10 5:33
Ian Shlasko1-Sep-10 5:33 
GeneralRe: changing skins Pin
V.1-Sep-10 9:49
professionalV.1-Sep-10 9:49 
GeneralRe: changing skins Pin
Ian Shlasko1-Sep-10 10:16
Ian Shlasko1-Sep-10 10:16 
QuestionChange style of application Pin
tonydang1-Sep-10 0:38
tonydang1-Sep-10 0:38 
AnswerRe: Change style of application Pin
#realJSOP1-Sep-10 2:25
professional#realJSOP1-Sep-10 2:25 
QuestionHow to post my example Pin
tonydang31-Aug-10 23:24
tonydang31-Aug-10 23:24 
AnswerRe: How to post my example Pin
Pete O'Hanlon1-Sep-10 0:21
mvePete O'Hanlon1-Sep-10 0:21 
AnswerRe: How to post my example Pin
AspDotNetDev1-Sep-10 9:31
protectorAspDotNetDev1-Sep-10 9:31 
QuestionDate Problem in SL Pin
Jagz W31-Aug-10 21:05
professionalJagz W31-Aug-10 21:05 
AnswerRe: Date Problem in SL Pin
Pete O'Hanlon31-Aug-10 21:36
mvePete O'Hanlon31-Aug-10 21:36 
GeneralRe: Date Problem in SL Pin
Jagz W1-Sep-10 3:16
professionalJagz W1-Sep-10 3:16 
GeneralRe: Date Problem in SL Pin
Pete O'Hanlon1-Sep-10 3:17
mvePete O'Hanlon1-Sep-10 3:17 

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.