canton7 / canton7/Stylet

Update Screens and Conductors page on Wiki to document ConductWith

Open
#96 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.1k
Forks
155
PR merge metrics
No merged PRs in 30d

Description

I am attempting to use Conductor.Collection.AllActive to house multiple unique UserControls within one screen.

When binding to the Items collection of a conductor, how can I specify which VM will be used in a ContentControl?

This seems to work:
``

However, when I close the screen, I get this error:
```
System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'IScreen') from 'Items' (type 'BindableCollection`1'). BindingExpression:Path=Items[0]; DataItem='MainViewModel' (HashCode=48883615); target element is 'ContentControl' (Name=''); target property is 'Model' (type 'Object') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index'
```

My assessment from the error is that the VM is being deleted before the View, and it's trying to directly access an array element that doesn't exist any more. I don't get a crash, just an error in the console.

My main view is a UserControl split into sections which each house its own UserControl. I want to be able to specify which Item from the Conductor's Items collection each UserControl uses. Is there a better/safer way than accessing the Items collection at a specific element?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Screens and Conductors wiki page and the ConductWith behavior described in the issue. Reproduce the Items[0] binding scenario while closing the screen, then document the supported way to associate each UserControl with its intended ViewModel and explain how the page should avoid the reported binding error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.