@@ -33,25 +33,45 @@ public partial class RepositoryCloneControl : GenericRepositoryCloneControl
3333 {
3434 readonly Dictionary < string , RepositoryGroup > groups = new Dictionary < string , RepositoryGroup > ( ) ;
3535
36+ static readonly DependencyPropertyKey RepositoriesViewPropertyKey =
37+ DependencyProperty . RegisterReadOnly (
38+ nameof ( RepositoriesView ) ,
39+ typeof ( ICollectionView ) ,
40+ typeof ( RepositoryCloneControl ) ,
41+ new PropertyMetadata ( null ) ) ;
42+
43+ public static readonly DependencyProperty RepositoriesViewProperty = RepositoriesViewPropertyKey . DependencyProperty ;
44+
3645 public RepositoryCloneControl ( )
3746 {
3847 InitializeComponent ( ) ;
3948
4049 this . WhenActivated ( d =>
4150 {
42- d ( this . OneWayBind ( ViewModel , vm => vm . Repositories , v => v . repositoryList . ItemsSource , CreateRepositoryListCollectionView ) ) ;
4351 d ( repositoryList . Events ( ) . MouseDoubleClick . InvokeCommand ( this , x => x . ViewModel . CloneCommand ) ) ;
4452 d ( ViewModel . CloneCommand . Subscribe ( _ => NotifyDone ( ) ) ) ;
4553 } ) ;
54+
4655 IsVisibleChanged += ( s , e ) =>
4756 {
4857 if ( IsVisible )
4958 this . TryMoveFocus ( FocusNavigationDirection . First ) . Subscribe ( ) ;
5059 } ;
60+
61+ this . WhenAnyValue ( x => x . ViewModel . Repositories , CreateRepositoryListCollectionView ) . Subscribe ( x => RepositoriesView = x ) ;
62+ }
63+
64+ public ICollectionView RepositoriesView
65+ {
66+ get { return ( ICollectionView ) GetValue ( RepositoriesViewProperty ) ; }
67+ private set { SetValue ( RepositoriesViewPropertyKey , value ) ; }
5168 }
5269
5370 ListCollectionView CreateRepositoryListCollectionView ( IEnumerable < IRepositoryModel > repositories )
5471 {
72+ if ( repositories == null )
73+ return null ;
74+
5575 var view = new ListCollectionView ( ( IList ) repositories ) ;
5676 Debug . Assert ( view . GroupDescriptions != null , "view.GroupDescriptions is null" ) ;
5777 view . GroupDescriptions . Add ( new RepositoryGroupDescription ( this ) ) ;
0 commit comments