File tree 2 files changed +11
-4
lines changed
reactiveui-simple-user-control/SimpleApp/SimpleApp 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -21,16 +21,19 @@ public partial class App : Application
21
21
{
22
22
public App ( )
23
23
{
24
- // This is the "magic" that automatically registers each view against the IViewFor<>
25
- // interface it implements. This is specific to Splat, and could be replaced by the
26
- // specific capabilities of another IoC library
27
- //
28
24
var assembly = Assembly . GetExecutingAssembly ( ) ;
29
25
var builder = new ContainerBuilder ( ) ;
30
26
27
+ // Since we're using the ReactiveUI.Autofac library this is all we need to do
28
+ // to wire up our views and view models. Since it's based on Autofac we can
29
+ // also freely inject any dependencies we've registered.
30
+ //
31
31
builder . RegisterForReactiveUI ( assembly ) ;
32
32
RxAppAutofacExtension . UseAutofacDependencyResolver ( builder . Build ( ) ) ;
33
33
34
+ // We've replaced Splat's default locator with the Autofac version so
35
+ // we can continue to use the code shown in the ReactiveUI examples
36
+ //
34
37
var view = ( Views . MainWindow ) Locator . CurrentMutable . GetService ( typeof ( IViewFor < MainWindowViewModel > ) ) ;
35
38
view . Show ( ) ;
36
39
}
Original file line number Diff line number Diff line change 20
20
<TextBlock HorizontalAlignment =" Center" VerticalAlignment =" Center" x : Name =" CurrentValue" FontSize =" 48" ></TextBlock >
21
21
</DockPanel >
22
22
23
+ <!-- This is the "magic" that allows ViewModel-first controls to work. -->
24
+ <!-- By using the VMVH from ReactiveUI we can let the library automatically -->
25
+ <!-- resolve the required view for us. The downside is we seem to lose any -->
26
+ <!-- design-time view of the actual control here in the parent window. -->
23
27
<reactiveUi : ViewModelViewHost Grid.Row=" 1" HorizontalContentAlignment =" Stretch" VerticalContentAlignment =" Stretch" x : Name =" CounterViewModel" ></reactiveUi : ViewModelViewHost >
24
28
</Grid >
25
29
</Window >
You can’t perform that action at this time.
0 commit comments