我已将此 itemtemplate 绑定在一个ObservableCollection<MembershipUserProfiled>
元素上,因此它可以显示在ListBox
.
<UserControl.Resources>
<ResourceDictionary>
<DataTemplate x:Key="ListItemElencoTemplate">
<Grid Background="#FFFFFF" Width="300">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Style="{DynamicResource label_default}" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Content="{Binding Path=FirstName}" Margin="0 0 0 3" />
<Label Grid.Column="1" Style="{DynamicResource label_default}" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Content="{Binding Path=LastName}" Margin="0 0 0 3" />
<Label Grid.Column="2" Style="{DynamicResource label_default}" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Content="{Binding Path=BaseUser.UserName}" Margin="0 0 0 3" />
<Button Content="Button" Style="{DynamicResource edit}" Click="Edit_Click" CommandParameter="{Binding Path=...}" HorizontalAlignment="Right" Grid.Column="4" Width="20" Height="20"/>
</Grid>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
一切正常,但我想将按钮绑定CommandParameter
到行的MembershipUserProfiled
对象,以便在单击操作上传递数据。
我尝试了不同的解决方案,但似乎没有任何效果。我正在尝试做的事情是可行的吗?