1
定義的組合框添加一個按鈕,我有這個ItemsControl
在我的XAML定義WPF:在DataTemplate中
<ItemsControl Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" ItemsSource="{Binding MyItems, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<Label HorizontalContentAlignment="Center" Grid.Column="0" Content="{Binding FirstProperty}"/>
<Label HorizontalContentAlignment="Center" Grid.Column="1" Content="{Binding SecondProperty}"/>
<Label HorizontalContentAlignment="Center" Grid.Column="2" Content="{Binding ThirdProperty}"/>
<ComboBox HorizontalAlignment="Center" ItemsSource="{Binding CBSource}" Grid.Column="2" Width="140" Visibility="{Binding HasCombobox, Converter={StaticResource BoolToVis}}">
<ComboBoxItem>
<Button Content="INeedAButtonHere"></Button>
</ComboBoxItem>
</ComboBox>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我需要添加到這樣一個Button
創建的每個ComboBox
,可能是放置在的底部由於ComboBox
有源碼,因此下拉菜單。顯示UserControl
時,我當前的代碼會引發異常(XamlParseError)。如何做到這一點?
你想在組合框的每個項目按鈕?或者只是每個組合框的按鈕? – mm8
只需爲每個組合框設置一個按鈕,放置在下拉框的底部 –