如何創建一個自定義控件,該控件採用UIElement
的列表並根據某些邏輯呈現它們?將UIElements添加到自定義控件(WPF)
因爲它會處理的UIElement
S,添加控件的最佳方式的列表將是相同的,即ListBox
或ComboBox
。
<local:SomeControl>
<Button Content="First"/>
<Label Content="Something other"/>
</local:SomeControl>
下面是用戶控件的XAML:
<UserControl x:Class="_2009_07_22_Wpf_Smooth_Scroller.SomeControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
MinHeight="100" MinWidth="100">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="Some title"/>
<!-- The inner UIElement to add content to -->
<Canvas x:Name="innerPanel" Grid.Row="1"/>
</Grid>
</UserControl>
我如何,例如,地方i控制到位置X = 50 * 1,Y = 40 *我?
令人驚訝的簡單。剛剛嘗試過。作品。謝謝! – 2009-07-22 10:31:00