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

  • Home
  • SEARCH
  • 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 7173525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:50:33+00:00 2026-05-28T15:50:33+00:00

I’m trying to dynamically change a Border Background property named Brush2, but I get

  • 0

I’m trying to dynamically change a Border Background property named “Brush2”, but I get the following error.

Unable to cast object of type ‘System.Windows.Media.Color’ to type
‘System.Windows.Media.Brush’.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Color x:Key="Brush0">#7F605F5F</Color>
    <Color x:Key="Brush1">#7F7E7E7E</Color>

    <Color x:Key="Color2">#7FFDFDFD</Color>
    <SolidColorBrush  x:Key="Brush2" Color="{DynamicResource Color2}" />

    <Color x:Key="Brush3">#7FFFFFFF</Color>
    <Color x:Key="Brush4">#BFFFFFFF</Color>
    <Color x:Key="Brush5">#F2FFFFFF</Color>
    <Color x:Key="Brush6">#FF6096E5</Color>
    <Color x:Key="Brush7">#FF9B7C35</Color>
    <Color x:Key="Brush8">#FFB0BAA1</Color>
    <Color x:Key="Brush9">#7F60605F</Color>
    <Color x:Key="Brush10">White</Color>



    <Style TargetType="{x:Type TabItem}" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>


                            <VisualStateGroup x:Name="CommonStates">
                                <!-- silver -->
                                <VisualState x:Name="Selected">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush8}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush8}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush0}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush9}"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>


                                <VisualState x:Name="Normal"/>


                                <VisualState x:Name="MouseOver">
                                    <!-- bronze -->
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush7}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush7}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[1].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush0}"/>
                                        </ColorAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="border">
                                            <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Brush9}"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>



                                <VisualState x:Name="Flashing">
                                    <Storyboard>
                                        <DoubleAnimation 
                                            Storyboard.TargetName="BorderGlass"
                                            Storyboard.TargetProperty="Opacity"
                                            From="0.0"
                                            To="1.0"                     
                                            Duration="0:0:0.33"
                                            AutoReverse="True"
                                            RepeatBehavior="Forever"/>
                                    </Storyboard>
                                </VisualState>


                                <VisualState x:Name="Disabled"/>
                            </VisualStateGroup>


                        </VisualStateManager.VisualStateGroups>

                        <Border x:Name="border" BorderThickness="3" CornerRadius="5,5,0,0">
                            <Border.BorderBrush>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{DynamicResource Brush0}" Offset="0"/>
                                    <GradientStop Color="{DynamicResource Brush1}" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{DynamicResource Brush6}" Offset="0.004"/>
                                    <GradientStop Color="{DynamicResource Brush6}" Offset="0.823"/>
                                    <GradientStop Color="{DynamicResource Brush10}" Offset="0.228"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="BorderGlass" BorderThickness="3" CornerRadius="5,5,0,0" Background="{DynamicResource Brush2}">
                            <Border.BorderBrush>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="{DynamicResource Brush3}" Offset="0"/>
                                    <GradientStop Color="{DynamicResource Brush4}" Offset="0.401"/>
                                    <GradientStop Color="{DynamicResource Brush5}" Offset="0.254"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                        </Border>

                        <ContentPresenter HorizontalAlignment="Center" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" ContentSource="Header"/>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



</ResourceDictionary>
  • 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-05-28T15:50:34+00:00Added an answer on May 28, 2026 at 3:50 pm

    The following code works, but I had to do this:

    Uri uri2 = new Uri("/Resources/DayModeTab2.xaml", UriKind.Relative);
    ResourceDictionary resDict2 = Application.LoadComponent(uri2) as ResourceDictionary;
    
    //Make some changes
    MobileApp.Get().Resources.MergedDictionaries.Add(resDict2);
    

    And also my poor naming scheme caused conflicts since I have Brush0 in 2 xaml files.

    <Border x:Name="BorderGlass" BorderThickness="3" CornerRadius="5,5,0,0" >
      <Border.Background>
        <SolidColorBrush Color="{DynamicResource Color2}" />
       </Border.Background>
    <Border.BorderBrush>
    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="{DynamicResource Brush3}" Offset="0"/>
      <GradientStop Color="{DynamicResource Brush4}" Offset="0.401"/>
      <GradientStop Color="{DynamicResource Brush5}" Offset="0.254"/>
    </LinearGradientBrush>
    </Border.BorderBrush>
    </Border>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.