Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Please anyone tell me how to give the image as background for border control OR
Is it possible to give image as border for image control in WPF(C#).
Thanks in Advance
Posted

1 solution

the following code is to change the background for WPF button

C#
<button content="Button" height="23" horizontalalignment="Left" margin="400,111,0,0" name="button1" verticalalignment="Top" width="75">
            <Button.Background>
                <imagebrush imagesource="/your Project;component/Images/BackGround.PNG" />
            </Button.Background>
        </Button></button>


Hope this will help

XML
<Border BorderThickness="5">
            <Border.BorderBrush>
                <ImageBrush ImageSource="/WCF_TEST;component/Images/Tulips.jpg"/>
            </Border.BorderBrush>
            <Image x:Name="ImageControl" Source="/WCF_TEST;component/Images/Hydrangeas.jpg"/>
        </Border>
 
Share this answer
 
v2
Comments
fjdiewornncalwe 26-Sep-12 9:32am    
My vote of 1: The OP has no interest in setting the background of a button, he wants to use an image to draw a border.
[no name] 26-Sep-12 22:59pm    
ya i have updated my solution.
ranjith m amin 27-Sep-12 0:40am    
Rite..
ranjith m amin 27-Sep-12 0:43am    
I have tried the same thing but it is showing image border at top and left side only, remaining two sides are blank. Border Image size and image box size are same.
What to do ?
[no name] 27-Sep-12 4:33am    
update the image tag with the following

<Image x:Name="ImageControl" Source="/WCF_TEST;component/Images/Hydrangeas.jpg" Margin="5"/>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900