如何使用混合和WPF在矩形上插入标签 [英] How do I insert a lable on a rectangle using blend and WPF
本文介绍了如何使用混合和WPF在矩形上插入标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,快问(我希望)......我在表格上有两个矩形,我想在左边的矩形上放一个标签。但是当我这样做的时候,我在左边丢失了我的矩形,最终看起来就像右边的矩形覆盖了整个窗口。
我将不胜感激任何帮助。 />
谢谢
这是左边矩形的代码...
< 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 =htt p://schemas.openxmlformats.org/markup-compatibility/2006
xmlns:local =clr-namespace:PrioKat
mc:Ignorable =d
Title =PrioKat Height =463.309Width =673.355BorderThickness =1ResizeMode =CanMinimizeallowsTransparency =TrueWindowStyle =None>
< window.background >
< lineargradientbrush endpoint = 0.5,1 startpoint = 0.5,0 >
< gradientstop color = 黑色 offset = 0 / >
< gradientstop 颜色 = #FF262344 offset = 1 / >
< / lineargradientbrush >
< / window.background < span class =code-keyword>>
< < span class =code-leadattribute> rectangle fill = #FF08081D horizontalalignment = 左 margin = - 4,0,0,1 stroke = 黑色 width = 151 / >
< / window >
这是正确的窗口...
< 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 =PrioKatHeight =463.309Width =673.355BorderThickness =1ResizeMode =CanMinimizeallowsTransparency =TrueWindowStyle =None>
< window.background >
< lineargradientbrush endpoint = 0.5,1 startpoint = 0.5,0 >
< gradientstop color = 黑色 offset = 0 / >
< gradientstop 颜色 = #FF262344 offset = 1 / >
< / lineargradientbrush >
< / window.background < span class =code-keyword>>
< < span class =code-leadattribute> rectangle fill = #FF08081D horizontalalignment = 左 margin = - 4,0,0,1 stroke = 黑色 width = 151 / >
< / window >
解决方案
这是左边矩形的代码......(因为你需要点击改进解决方案才能看到剩下的代码)
< pre lang =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:// schema s.openxmlformats.org/markup-compatibility/2006
xmlns:local =clr-namespace:PrioKat
mc:Ignorable =d
Title =PrioKatHeight = 463.309Width =673.355BorderThickness =1ResizeMode =CanMinimizeallowsTransparency =TrueWindowStyle =None>
< window.background >
< lineargradientbrush endpoint = 0.5,1 startpoint = 0.5,0 >
< gradientstop color = 黑色 offset = 0 / >
< gradientstop 颜色 = #FF262344 offset = 1 / >
< / lineargradientbrush >
< / window.background < span class =code-keyword>>
< < span class =code-leadattribute> rectangle fill = #FF08081D horizontalalignment = 左 margin = - 4,0,0,1 stroke = 黑色 width = 151 / >
< / window >
这是正确的矩形...
< 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 =PrioKatHeight =463.309Width =673.355BorderThickness =1ResizeMode =CanMinimizeallowsTransparency =TrueWindowStyle =None>
< window.background >
< lineargradientbrush endpoint = 0.5,1 startpoint = 0.5,0 >
< gradientstop color = 黑色 offset = 0 / >
< gradientstop 颜色 = #FF262344 offset = 1 / >
< / lineargradientbrush >
< / window.background < span class =code-keyword>>
< < span class =code-leadattribute> rectangle fill = #FF08081D horizontalalignment = 左 margin = - 4,0,0,1 stroke = 黑色 width = 151 / >
< / window >
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...
<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...
<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>
解决方案
Here's the code for the left rectangle... (and for reason, you have to click improve solution to see the rest of the code)
<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...
<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>
这篇关于如何使用混合和WPF在矩形上插入标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文