내 요구 사항에 따라 편집 단추/하이퍼 링크 행에 & 헤더 행에 RadGridView 컨트롤에 새 단추 추가/하이퍼 링크가 있어야합니다.이 단추는로드됩니다. 데이터의 추가/편집을 실시하는 아이 윈도우의 pop-up. 내 응용 프로그램은 Prism 4.1 & MVVM (View 접근 방식을 작성하는 모델)을 사용하여 Silverlight 5에 있습니다. RadGridView 편집 단추 명령이 프리즘에서 바인딩되지 않습니다. 4.1 Silverlight 5
나는 이런 버튼 생성 :<telerik:GridViewColumn Width="80">
<telerik:GridViewColumn.Header>
<StackPanel Orientation="Horizontal"
VerticalAlignment="Top"
HorizontalAlignment="Center">
<telerik:RadButton DataContext="{Binding DataContext ,ElementName=LayoutRoot}"
prism:Click.Command="{Binding AddUserEventCommand}"
Content="Add User">
<!-- <Image Source="../../Assets/Images/icon_user_add.png"
Cursor="Hand" Stretch="None" Width="32" Height="32"/>-->
</telerik:RadButton>
</StackPanel>
</telerik:GridViewColumn.Header>
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<telerik:RadButton prism:Click.Command="{Binding DataContext.EditUserEventCommand}">
<Image Source="../../Assets/Images/icon_user_update.png"
Cursor="Hand"
Stretch="None" Width="32" Height="32" >
</Image>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
을하지만 내 클릭 이벤트가 작동하지 않습니다?
같은 Button을 내게 주었을 때 그 Grid를 내게주었습니다. 그 코드 는 다음과 같이이다 :
<telerik:RadButton Command="{Binding AddUserEventCommand}" Content="Add User" VerticalAlignment="Top"></telerik:RadButton>
몇 스레드 당으로 내가 DataContext에이 문제가 될 수 있다는 것을 발견했다. https://compositewpf.codeplex.com/discussions/64514 는 그래서 의해 추가 버튼의 DataContext에 변경 시도 :
DataContext="{Binding DataContext ,ElementName=LayoutRoot}"
하지만 여전히 성공.
EditUserEventCommand, AddUserEventCommand는 모두 DelegateCommand입니다. 내 ViewModel을 코드에서
은 다음과 같이이다 :
public class UsersTabViewModel : TabViewModelBase , IUsersTabViewModel
{
/// Constructor
public UsersTabViewModel(IUsersTabView view):base(view) {
this.Header = "Users";
this.Title = "Users";
this.IsSelected = true;
ctx = new UserRiaDomainContext();
fillUser();
doEventBinding();
}
private void doEventBinding() {
AddUserEventCommand = new DelegateCommand(AddUser, CanAddUser);
UpdateUserEventCommand = new DelegateCommand(EditUser, CanEditUser);
}
/// Bind with User Add
private DelegateCommand _addUserEventCommand;
public DelegateCommand AddUserEventCommand
{
get { return _addUserEventCommand; }
set
{
_addUserEventCommand = value;
OnPropertyChanged("AddUserEventCommand");
}
}
/// Bind with User Update in Grid Row
private DelegateCommand _updateUserEventCommand;
public DelegateCommand UpdateUserEventCommand {
get { return _updateUserEventCommand; }
set {
_updateUserEventCommand = value;
OnPropertyChanged("UpdateUserEventCommand");
}
}
......
}
어떻게 그것을 해결하기 위해?
이것은 나를 위해 일하므로 정말 고마워요! – MartynJones87