- KeldorKatarn
- Posts: 193
- Joined:
How bad are binding errors?
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
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.)
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
Code: Select all
<!-- ... -->
<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}" />
<!-- ... -->
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.)
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: How bad are binding errors?
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.
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
- Posts: 193
- Joined:
Re: How bad are binding errors?
TreeView.SelectedItem is not bindable :D That's the problem.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: How bad are binding errors?
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
- Posts: 193
- Joined:
Re: How bad are binding errors?
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: Ahrefs [Bot], Bing [Bot] and 70 guests