I have an ItemsControl
that is data bound to a list of decimal
s. I need to add one extra control to the ItemsControl
(an option to specify the number manually). Is there a way to do this in XAML? I know I can manually add the item in the code behind, but I'm trying to understand WPF a little better and want to see if there is a declarative way to do it.
Note that modifying the list I'm binding to so that it includes the extra button (possibly by changing to a list of string
s instead of decimal
s) isn't a good alternative because I want to attach a command to that last button.
Also, adding an extra button after the ItemsControl
isn't a good option either, because my control uses a UniformGrid
and I want my extra control in that same grid.
Here is my XAML:
<ItemsControl ItemsSource="{Binding PossibleAmounts}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Name="ButtonsGrid">
</UniformGrid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button>
<TextBlock Text="{Binding StringFormat='{0:C}'}"/>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Basically, I want one more button in the UniformGrid.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…