Data binding: One vs two way [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I don't currently have an example for my question. I would just like to get some insight of the following : When should one use one or two way data binding in XAML ?
Thank you in advance for the time you take to answer this !

In summary: use OneWay if the property is readonly, use TowWay if you want to change it from your view.
TwoWay updates the target property or the property whenever either the target property or the source property changes.
OneWay updates the target property only when the source property changes.
REF:Binding.Mode Property. and BindingMode Enumeration

Use OneWay if you only want to update the view from your model.
TwoWay also updates the model if you change the view. e.g. a TextBox. So you should use it when you want that your view can affect the model.
MSDN-Page BindingMode

Related

Is it smart to replace ICollection with ObservableCollection<T> wpf ef [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm a beginner with wpf app building and entity framework.
I'm building my first wpf app, I found out I should have replaced my auto-generated ICollection with ObservableCollection.
The problem is that I already did most of my code so far but am having some issues with INotifyPropertyChanged. I see all the codes about INotifyPropertyChanged use ObservableCollection.
Is it bad if I go to my auto-generated code now and replace the ICollection with ObservableCollection? Will it mess up my app?
ObservableCollection is only useful if you want to add items to a collection at some point, and have a UI control automatically update to display the added / deleted items. ObservableCollection also has potential threading issues - any change to the collection must be done on the same thread as it was created on.
It has nothing to do with reflecting changes to properties of individual elements within the collection - that is what INotifyPropertyChanged is for.

Using a View as SubView in different Views WPF [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a View - which is a UserControl - that shows different information and gets updated by its corresponding ViewModel.
Now I want to use this View in different other Views, which are UserControls as well.
I tried different approaches like using ResourceDictionaries and other stuff, but I couldn´t get a satisfying result.
You have to put a ContentControl in views that are importing your view and set the ContentControl's Content to the given view

How I can make an Autocomplete TextField in WPF? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
How I can make an Autocomplete Text Field in WPF?
How I can include multiple value in text field.
Actually I'm trying to make an search bar in which Products are fetched from database and include in text field then.When i type a keyword it should be display an suggestion.
Re-template ComboBox to make it looks like TextBox.
Extend ComboBoxItem so that we can hightlight the already entered part in the dropdown list.
Get reference to the TextBox part of the ComboBox, and hook up TextBox.TextChanged event.
In the TextBox.TextChanged event handler, we filter the underlying datasource and create new list source with our customized ComboBox Items.
Hope this will be helpful.
Thank you

INotifyPropertyChanged in a Model [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
In this tutorial INotifyPropertyChanged is in Model - not in ViewModel.
Is it correct and acceptable? What are standards ?
INotifyPropertyChanged is just an interface that provides functionality, it's not MVVM specific in any way. Classes generated by Linq to SQL or the like also usually implement it for example.
It is correct! You should raise PropertyChanged where you change the property (so in the model in your case). In other cases it might be in the view model but it can really be anywhere.
I think the confusion starts because the properties in the view model must raise the PropertyChanged event to update the UI. That does however not mean that the PropertyChanged event must have its origin in the view model.

Indenting listview item with icon in c# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I want to create list view with indented icon and I came across that:
There is a solution, but it's non-dotnet and I was wondering how I could achieve this with C#?
Thanks!
See this MSDN page. Use the IndentCount property of the ListViewItems.
However see the remark there:
The IndentCount property can be used only when the View property of
the containing ListView is set to Details, and the SmallImageList
property of the ListView is set.
The example there works easily.

Categories