KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

How bad are binding errors?

30 Apr 2021, 16:45

Very simple question regarding the performance impact of binding errors. How bad are they really?

In my normal WPF development we're trying to avoid Binding errors but some we just ignore since they are just artifacts of something not yet being initialized or whatnot and not really worth avoiding.

this is an example
                <!-- ... -->
                <TreeView
                    Background="Transparent"
                    ItemsSource="{Binding Root, Mode=OneWay}">
                </TreeView>
                <ListBox
                    Grid.Column="2"
                    ItemsSource="{Binding SelectedItem.Files, ElementName=TreeView, Mode=OneWay}"
                    SelectedItem="{Binding SelectedFile, Mode=TwoWay}" />
                <!-- ... -->
Since when the view is launched and when it's shut down TreeView.SelectedItem will be null, the ItemsSource Binding of the ListBox reports a failed Binding, since the nested Property Files cannot be reached. A circumvention via the ViewModel is also not possible since TreeView.SelectedItem is readonly and cannot receive a binding.
Now this works just fine.. but with verbose logging Noesis reports a Binding error here. One which from the top of my head I don't really know how to avoid since ListBox needs its regular DataContext for the SelectedItem Binding.

So does this sort of thing impact performance much in Noesis or is this safe to just ignore?
(Also if anybody knows hot to do this binding better I'm all ears. I've basically run into this in my WPF time so many times and nobody has any clue how else to do this pretty much.)
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: How bad are binding errors?

30 Apr 2021, 19:35

There is no performance impact for Binding errors, they are just informative.

In the scenario you are proposing, a solution to avoid the binding error could be to have another property in the view model with the selected item in the TreeView and bind to that property instead. You'll need to update that property when selection changes in the TreeView.
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: How bad are binding errors?

30 Apr 2021, 19:49

TreeView.SelectedItem is not bindable :D That's the problem.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: How bad are binding errors?

30 Apr 2021, 19:56

I know, that is why I said you'll need to update that new property in the SelectedChanged event instead of using a two-way binding :)
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: How bad are binding errors?

30 Apr 2021, 20:12

Yeah I've done that before with some Behaviors. The problem is just that the VM property can run out of sync that way, but oh well.

Who is online

Users browsing this forum: Bing [Bot] and 87 guests