Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone, Quick question (I hope)... I have two rectangles on a form and I want to put a lable on the left rectangle. But when I do, I lose my rectangle on the left and it ends up looking like the right rectangle covers the whole window.

I would appreciate any help.

thanks

Here's the code for the left rectangle...

HTML
<window x:class="MainWindow" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PrioKat"
        mc:Ignorable="d"
        Title="PrioKat" Height="463.309" Width="673.355" BorderThickness="1" ResizeMode="CanMinimize" AllowsTransparency="True" WindowStyle="None">
    <window.background>
        <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0">
            <gradientstop color="Black" offset="0" />
            <gradientstop color="#FF262344" offset="1" />
        </lineargradientbrush>
    </window.background>
    <rectangle fill="#FF08081D" horizontalalignment="Left" margin="-4,0,0,1" stroke="Black" width="151" />
</window>

And this is the right window...

HTML
<window x:class="MainWindow" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PrioKat"
        mc:Ignorable="d"
        Title="PrioKat" Height="463.309" Width="673.355" BorderThickness="1" ResizeMode="CanMinimize" AllowsTransparency="True" WindowStyle="None">
    <window.background>
        <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0">
            <gradientstop color="Black" offset="0" />
            <gradientstop color="#FF262344" offset="1" />
        </lineargradientbrush>
    </window.background>
    <rectangle fill="#FF08081D" horizontalalignment="Left" margin="-4,0,0,1" stroke="Black" width="151" />
</window>
Posted
Updated 19-Aug-15 6:02am
v3
Comments
CHill60 19-Aug-15 9:54am    
Post the xaml

1 solution

Here's the code for the left rectangle... (and for reason, you have to click improve solution to see the rest of the code)

HTML
<window x:class="MainWindow" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PrioKat"
        mc:Ignorable="d"
        Title="PrioKat" Height="463.309" Width="673.355" BorderThickness="1" ResizeMode="CanMinimize" AllowsTransparency="True" WindowStyle="None">
    <window.background>
        <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0">
            <gradientstop color="Black" offset="0" />
            <gradientstop color="#FF262344" offset="1" />
        </lineargradientbrush>
    </window.background>
    <rectangle fill="#FF08081D" horizontalalignment="Left" margin="-4,0,0,1" stroke="Black" width="151" />
</window>

And this is the right rectangle...

HTML
<window x:class="MainWindow" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:PrioKat"
        mc:Ignorable="d"
        Title="PrioKat" Height="463.309" Width="673.355" BorderThickness="1" ResizeMode="CanMinimize" AllowsTransparency="True" WindowStyle="None">
    <window.background>
        <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0">
            <gradientstop color="Black" offset="0" />
            <gradientstop color="#FF262344" offset="1" />
        </lineargradientbrush>
    </window.background>
    <rectangle fill="#FF08081D" horizontalalignment="Left" margin="-4,0,0,1" stroke="Black" width="151" />
</window>
 
Share this answer
 
v3
Comments
CHill60 19-Aug-15 10:41am    
I added the "pre" tags so you don't have to click on Improve solution to see the rest of it
jumper77 19-Aug-15 11:00am    
Thank you very much. Does the xaml look bad or anything? Extra info... it does the same thing no matter what control I try to use.
jumper77 19-Aug-15 11:14am    
Don't mean to be "too" dumb, but I just realized that what I thought was a rectangle on the right is actually the window
CHill60 19-Aug-15 12:00pm    
Sorry I've been a bit silly. I'm going to move everything from this solution into the original post, then delete this solution so that your question appears back in the list of unanswered questions. If you need to add or change anything afterwards use the Improve question link

Ignore that delete bit, just realised you've accepted this answer so you fixed it for yourself. Bad day reading today!
jumper77 19-Aug-15 12:09pm    
I haven't accepted a solution yet (thought I may have and didn't realize it). I really do thank you for the help. I am at a loss. I've been retired for many years (software engineer), and I just thought I would play around a bit... a LOT has changed...

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