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 6075077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:27:14+00:00 2026-05-23T10:27:14+00:00

In my application resources I have: <Application.Resources> <Border x:Key=border1 BorderBrush={x:Null} BorderThickness=0 Height=159 Width=5 >

  • 0

In my application resources I have:

    <Application.Resources>

    <Border x:Key="border1" BorderBrush="{x:Null}" BorderThickness="0" Height="159"  Width="5" >
        <Border.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFFC0C0C" Offset="0" />
                <GradientStop Color="#63FF0000" Offset="0.999" />
                <GradientStop Color="#6AFE0000" Offset="0.048" />
            </LinearGradientBrush>
        </Border.Background>
    </Border>

</Application.Resources>

I will like to add that border to a stack panel like:

            Border temp = new Border();
            temp = (Border)FindResource("border1");
            temp.Name = "bar" + i;
            stackPanel1.Children.Add(temp);

This works fine. The only problem is that I would like to add two instances of that border. Therefore I have placed that inside a loop:

            for (int i = 0; i < 10; i++)
        {
            Border temp = new Border();
            temp = (Border)FindResource("border1");
            temp.Name = "bar" + i;
            stackPanel1.Children.Add(temp);
        }

on the second iteration I get the error:

enter image description here

But to me there does not seem to be a parse exeption because note how there is no problem on the first iteration:

enter image description here

How could I use a resource several times? I know I could create that resource dynamically but I need to actually use the resource.

  • 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-23T10:27:14+00:00Added an answer on May 23, 2026 at 10:27 am

    If you add x:Shared=”false” to your resource definition, it should work:

    <Border x:Key="border1" x:Shared="false" BorderBrush="{x:Null}" BorderThickness="0" Height="159"  Width="5" >
        <Border.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFFC0C0C" Offset="0" />
                <GradientStop Color="#63FF0000" Offset="0.999" />
                <GradientStop Color="#6AFE0000" Offset="0.048" />
            </LinearGradientBrush>
        </Border.Background>
    </Border>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Button inside application.resources DataTemplate : <DataTemplate x:Key=contactItem DataType={x:Type Model:Contact}> <Button x:Name=openButton Style={StaticResource
I have in my application resources file brush: <SolidColorBrush x:Key=MainColor Color=#FF15428B /> I want
Let's say we have a grails web application exposing several resources. tags urls users
I have an application that differs for different languages by resources. Is there a
I have an application on the Compact Framework that has some large embedded resources
How can I reduce resources inside my application? I have tried a number of
I have a App.xaml template : <Application.Resources> <!-- template for recent history --> <DataTemplate
I have a DataTemplate in app.xaml that binds a view to a viewmodel. <Application.Resources>
In my solution, I have one application project, which defines all the resources -
I have couple resource DLLs that I currently load when application starts using following

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.