© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
19 replies
᲼᲼᲼᲼᲼᲼᲼᲼᲼

❔ Changing TextBlock Background property in a static method

The method needs to be static (unless there are implementations of LowLevelKeyboardProc that doesn't require it). I am looking for any solution or workaround that will allow for it. Ultimately background needs to be changed on every click. My only idea for now is using INotifyPropertyChanged but all its uses I've seen are about view models so idk if it's possible to use it for this property too.

I can post rest if needed
public static IntPtr hookProc(int code, IntPtr wParam, IntPtr lParam)
    {
        if (code >= 0)
        {
            int vkCode = Marshal.ReadInt32(lParam);
            if (wParam == (IntPtr)WM_KEYDOWN)
                if (vkCode == 65)
                {
                    A.Background = new SolidColorBrush(Colors.Red);
                }
        }

        return CallNextHookEx(hhook, code, (int)wParam, lParam);
    }
public static IntPtr hookProc(int code, IntPtr wParam, IntPtr lParam)
    {
        if (code >= 0)
        {
            int vkCode = Marshal.ReadInt32(lParam);
            if (wParam == (IntPtr)WM_KEYDOWN)
                if (vkCode == 65)
                {
                    A.Background = new SolidColorBrush(Colors.Red);
                }
        }

        return CallNextHookEx(hhook, code, (int)wParam, lParam);
    }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Static property override
C#CC# / help
2y ago
Static property issues
C#CC# / help
2y ago
Border.Background property
C#CC# / help
16mo ago
Cannot access non-static method in static context?
C#CC# / help
4y ago