【发布时间】:2010-11-21 14:54:58
【问题描述】:
我有一个包含删除按钮的 WPF UserControl,我想将整个 UserControl 作为 CommandParameter 传递。
当前绑定设置为 CommandParameter="{Binding RelativeSource={RelativeSource Self}}" 这给了我按钮,但我怎样才能获得整个控件?
有人可以帮忙吗?
干杯,
安迪
<UserControl x:Class="GTS.GRS.N3.Controls.LabelledTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="155" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Name="label" HorizontalAlignment="Left" Width="96">Label</Label>
<TextBox Name="textBox" Grid.Column="1" />
<Button Grid.Column="2" Style="{DynamicResource CloseButton}" Command="{Binding RemoveCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}" Visibility="{Binding RemoveVisible}"></Button>
</Grid>
</UserControl>
【问题讨论】:
标签: wpf binding user-controls