Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:23:54+00:00 2026-06-15T15:23:54+00:00

How do I bind something like <Color x:Key=SomeColor /> to a dependency property with

  • 0

How do I bind something like <Color x:Key="SomeColor" /> to a dependency property with Caliburn Micro?

I need to be able to change Color at run-time and have it immediately updated in all things that use it.

Solution:


XAML in SomeClassView.xaml

<SomeControl.Resources>
    <SolidColorBrush x:Key="ControlBrush" />
</SomeControl.Resources>

C# in SomeClassViewModel.cs

[Export(typeof(MainWindowViewModel))]
public class MainWindowViewModel : PropertyChangedBase
{
    private SolidColorBrush _controlBrush;

    public SolidColorBrush ControlBrush
    {
        get { return _controlBrush; }
        set
        {
            _controlBrush = value;
            NotifyOfPropertyChange(() => ControlBrush);
        }
    }
}

The problem was exactly what Charleh said, I just totally forgot that not everything in WPF can be a DependencyProperty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:23:56+00:00Added an answer on June 15, 2026 at 3:23 pm

    You can’t usually directly bind a Color object, you need to use a SolidColorBrush (for solid colour), as that’s what most UI objects expect.

    e.g.

    TextBox.Background expects Brush, of which SolidColorBrush is a subclass of. There are other types of brushes that produce different fills such as LinearGradientBrush

    Have a look here:

    How can I bind a background color in WPF/XAML?

    Can you provide some screenshots of what you expect and the XAML?

    Edit:

    Ok well what you want is pretty simple to achieve, not really related to Caliburn.Micro at all 🙂

    Create your styles as usual, but bind the brushes Color property dynamically using DynamicResource. When you update the colour itself, the resource binding will be evaluated again and the colours will change.

    Example XAML:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <Color x:Key="TestColor" A="255" R="255" G="0" B="0"></Color>
            <Style x:Key="ButtonStyle" TargetType="Button">
                <Setter Property="Background">
                    <Setter.Value>
                        <SolidColorBrush Color="{DynamicResource TestColor}"></SolidColorBrush>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>
        <Grid>
            <StackPanel>
                <Button Click="Button_Click" Style="{StaticResource ButtonStyle}">Red</Button>
                <Button Click="Button_Click_1" Style="{StaticResource ButtonStyle}">Blue</Button>
            </StackPanel>
        </Grid>
    </Window>
    

    Code-behind:

    namespace WpfApplication1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                Resources["TestColor"] = Color.FromArgb(255, 255, 0, 0);
            }
    
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                Resources["TestColor"] = Color.FromArgb(255, 0, 0, 255);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I'd like to bind function A to all inputs. Something like this: $('input').bind('change',
I need to bind a simple template method to LUA, something like void addComponent<T>(IComponent*);
I need to bind an ASP.NET control something like so: <asp:label ID=lblName Text=<%# GetName())
How can i bind a expressjs server to a specific IP Something like app.listen(8888,
I'm trying to figure out correct way how to bind something like this with
When i do something like this: public static void BindData<T>(this System.Windows.Forms.Control.ControlCollection controls, T bind)
I'd like to bind a list of dates to the BlackoutDates property but it
Is there a way to bind to the instance of another control? Something like
If I want to bind something like a combobox in the code-behind I have
Can you group jQuery's events like with switch(); ? Something like: $(element).bind({ blur: keyup:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.