@@ -33,25 +33,45 @@ public partial class RepositoryCloneControl : GenericRepositoryCloneControl
33
33
{
34
34
readonly Dictionary < string , RepositoryGroup > groups = new Dictionary < string , RepositoryGroup > ( ) ;
35
35
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
+
36
45
public RepositoryCloneControl ( )
37
46
{
38
47
InitializeComponent ( ) ;
39
48
40
49
this . WhenActivated ( d =>
41
50
{
42
- d ( this . OneWayBind ( ViewModel , vm => vm . Repositories , v => v . repositoryList . ItemsSource , CreateRepositoryListCollectionView ) ) ;
43
51
d ( repositoryList . Events ( ) . MouseDoubleClick . InvokeCommand ( this , x => x . ViewModel . CloneCommand ) ) ;
44
52
d ( ViewModel . CloneCommand . Subscribe ( _ => NotifyDone ( ) ) ) ;
45
53
} ) ;
54
+
46
55
IsVisibleChanged += ( s , e ) =>
47
56
{
48
57
if ( IsVisible )
49
58
this . TryMoveFocus ( FocusNavigationDirection . First ) . Subscribe ( ) ;
50
59
} ;
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 ) ; }
51
68
}
52
69
53
70
ListCollectionView CreateRepositoryListCollectionView ( IEnumerable < IRepositoryModel > repositories )
54
71
{
72
+ if ( repositories == null )
73
+ return null ;
74
+
55
75
var view = new ListCollectionView ( ( IList ) repositories ) ;
56
76
Debug . Assert ( view . GroupDescriptions != null , "view.GroupDescriptions is null" ) ;
57
77
view . GroupDescriptions . Add ( new RepositoryGroupDescription ( this ) ) ;
0 commit comments