是否可以將參數發送到在XAML中定義的控件?
例如,如果我有這樣的XAML:將參數發送到XAML中定義的控件
<UserControl x:Class="Controls.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary Source="..\Colors.xaml" />
</UserControl.Resources>
<Grid>
<Polygon x:Name="plgPoly" Points="0,0 100,0 100,100 0,0" />
</Grid>
</UserControl>
但是當我建立我的「多邊形」我想給它協調這取決於包含它(如控制:this.Height,this.Width,等等......)或在父控制中定義的其他控件上。
可能嗎?怎麼樣?
我想我可以在中定義自己的PointsCollection,然後將其綁定到我的多邊形。我會在定義中進行綁定。這將解決問題,對嗎? –
Idov
但我不確定這是否令您滿意,但您可以在這裏找到關於綁定資源的一些信息:http://blogs.msdn.com/b/wpfsdk/archive/2006/10/19/wpf -basic-data-binding-faq.aspx和這裏:http://msdn.microsoft.com/en-us/library/ms752326.aspx#creating。 –