You can use whatever you want, I was just pointing out that WPF is specifically designed with MVVM in mind. That doesn't mean you have to use MVVM in WPF. That means that WPF + MVVM is going to provide you with the cleanest code.
i have one user control in which i have placed 15 label controls,now i want to bind their content with an observableCollection, in which i am filling string values.
let me clear once again, i am filling list which is observableCollection and want to show each item in list as label values in usercontrol.
i have a application with ComboBox, the combobox contain the network adapters from local machine and i want when the application start the combobox will be marked (my default is blue) as if I pressed the button myself.
I have a method which saves my main window's position using isolated storage. Another method is responsible for loading the position. Easy. I call the "save" when closing the main window and the "load" when opening the window. Easy
But when the saved postion is applied to the newly opening window, I see the window appear briefly in the default position before it is relocated to the desired saved postion. This is annoying. Any idea on how to prevent that?
the problem when i see the link you gave me is to get panic first because its looks like very complicate compare to Winform properties
i don't know how to use in all this elements, i will glad to learn
On a WPF window, there is a TextBox which is bound to a property of number type (e.g. an int). When the user input contains characters (e.g. 12w34), the conversion to a number fails, and the setter of the underlying property does not get called, i.e. the property stays unchanged. But the textbox automatically receives a red border indicating that something went wrong.
I conclude that the data format error somehow found its way to the UI. Now I want to get informed about that error, so that I know that there is a discrepancy between the UI and the underlying ViewModel object.
For the purpose of learning, I do not want to prevent character input now.
How can I access that error, either when it just has been raised or somewhen later when I want to validate the object?
Thanks for the links. But they do not cover my problem: I do not care for a rule that my int must be between 1 and 99 or something like that, but that it must be an int! Just check the demo program of your second link: in the age field enter "1" and leave the field => it is ok. Then come back and add a letter, e.g. "w1" => it stays valid. Why? Exactly because of the problem I described above: the setter of the age property is not called now, the property's value is still 1, and that's ok. But not ok for me, because the UI shows a different (illegal) value.
How do you cope with such problems? Do you use a fully fledged WPF framework which handles such cases?
Also the Attached Behavior tries to prevent the problem, not to solve it after it has come to existence. At least, the framework you suggested (thanks for the link) covers copy&paste as an input method.
But still the problem that the UI contains "illegal" input exists:
It could be appropriate to explicitly allow entering wrong input. E.g. when using a barcode reader, I would not silently filter out unwanted characters, I'd rather tell the user that something wrong happened, e.g. he scanned from the wrong label.
And there might be input methods which do not use keyboard or copy&paste. Imagine an assistive technology which sends a WM_SETTEXT to the textbox...
There might be cases where preventing the wrong input by keyboard might be too complicated, i.e. here the wrong input would be possible, and the error happens when WPF tries to convert from string to the required datatype. A custom converter (IValueConverter) cannot directly talk with the ViewModel, exceptions would be handled by the WPF databinding classes.
Currently my impression is that I should change some properties in my ViewModel to string, since a conversion from string (TextBox.Text) to a string cannot fail. The property setter of the ViewModel then has to do the conversion to the type of the property in the underlying business object, and exceptions raised here can be easily caught. This means that the ViewModel class get even more bloated. But I'd easily cope with another bug of WPF: it always uses a decimal point, even when Windows regional settings tell that it should be a decimal comma.
I made a xps reader with the DocumentViewer control.How can I reader the xps file with DocumentStructView just like the doc file in Office Word open.- -!Sorry,my English is poor!Thanks.
public int ListInXpsDoc(string srcXpsDocument)
int numImages = 0;
int numPages = 0;
XpsDocument document = new XpsDocument(srcXpsDocument, FileAccess.Read);
IXpsFixedDocumentSequenceReader docSequence = document.FixedDocumentSequenceReader;
if (docSequence != null)
We're going to use Silverlight 5 for an out-of-browser application and need to have an individual title of the main window. In Silverlight 4 it was not possible to set this property as far as I know (See this issue). By default the main window has the title of the project followed by "Application". Does Silverlight 5 bring the ability to change the main window title? Maybe even during runtime via data binding?