Xceed DataGridControl을 Caliburn Micro에 바인딩하고 싶습니다. 바인딩을 설정하는 가장 좋은 방법은 무엇입니까, 내보기 모델에서 ICommands없이 Caliburn 스타일 메서드를 사용하고 싶습니다. Enter 키를 누르거나 그리드를 더블 클릭하면 OpenContract(Contract c)
메서드를 호출해야합니다.바인딩 Xceed DataGridControl with Caliburn Micro
보기 :
<xcdg:DataGridControl ItemsSource="{Binding Contracts}" AutoCreateColumns="False">
<xcdg:DataGridControl.InputBindings>
<KeyBinding Key="Enter" Command="{Binding Path=OpenContractCommand}" CommandParameter="{Binding ElementName=DataGrid, Path=SelectedItems}"/>
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding Path=OpenContractCommand}" CommandParameter="{Binding ElementName=DataGrid, Path=SelectedItems}"/>
</xcdg:DataGridControl.InputBindings>
<xcdg:DataGridControl.View>
<xcdg:TableView AllowColumnChooser="True" ShowFixedColumnSplitter="False" AllowRowResize="False" ShowRowSelectorPane="False" UseDefaultHeadersFooters="False" ColumnStretchMode="Last">
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:ColumnManagerRow AllowColumnReorder="True" AllowSort="True" AllowColumnResize="True" AllowAutoFilter="False" />
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Name" Title="Name"></xcdg:Column>
<xcdg:Column FieldName="CustomerName" Title="Customer"></xcdg:Column>
</xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
뷰 모델 :
public class ContractViewModel : Screen
{
public BindableCollection<Contract> Contracts { get; private set; }
private ContractRepository _repository;
public ContractViewModel(ContractRepository repository)
{
_repository = repository
}
public async void OnViewLoaded()
{
Contracts.Clear();
Contracts.AddRange(_repository.GetAll());
}
public IEnumerable<IResult> OpenContract(Contract contract)
{
yield return;
}
}
당신이 작업에 관하여 [모두 살펴 찍은 적이 ] (https://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Actions&referringTitle=Documentation) 위키. –