|
You don't use MVC in WPF, you use MVVM.
|
|
|
|
|
I can use mvc with windows forms?
|
|
|
|
|
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.
sorry for bad English.
Regards
|
|
|
|
|
Why do you have exactly 15 labels? Are there never going to be more than 15 items in the collection? I'd recommend looking into the ListView control as an alternative.
|
|
|
|
|
Dear all,i want to know that there is any event occurs when children elements added to stackpanel?
|
|
|
|
|
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.
how can i do it ?
|
|
|
|
|
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?
Thx
|
|
|
|
|
When are you setting the window position? Sounds like you are setting it too late. Set it when the window is created, but before its shown.
|
|
|
|
|
recently i move from winform to WPF and i found that is little hard to find all the properties from XAML, i want to change the default ComboBox DropDownStyle but i cant find it.
thanks
|
|
|
|
|
You can find the Drop down style here[^].
However, for styling, its always easier to use Expression Blend (it has a steep learning curve though).
|
|
|
|
|
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
|
|
|
|
|
Hello!
I must figure out the WorkingAreas of each connected Monitor.
SystemInformations.VirtualScreen/Left/Top/Width/Height does not help me out, since the VirtualScreen is the Union of all WorkAreas, an there are "dead spaces", which are not displayed by any Monitor.
How is that to archieve?
|
|
|
|
|
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?
|
|
|
|
|
The Validation.Errors property[^] and the IDataErrorInfo interface[^] can help you capture and display the error.
|
|
|
|
|
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?
|
|
|
|
|
Bernhard Hiller wrote: How do you cope with such problems? Do you use a fully fledged WPF framework
which handles such cases?
Well, I would use an Attached Behavior to handle this. Something like this[^] one.
|
|
|
|
|
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.
|
|
|
|
|
in my toolbox calendar control is not .how to add in calendar control in it
nikunj
|
|
|
|
|
|
Which platform is it for? Silverlight or WPF?
|
|
|
|
|
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.
<pre lang="c#">
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)
{
foreach (IXpsFixedDocumentReader docSeqDocument in docSequence.FixedDocuments)
{
foreach (IXpsFixedPageReader docPage in docSeqDocument.FixedPages)
{
numPages++;
}
}
}
document.Close();
return numPages;
}
</pre>
|
|
|
|
|
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?
|
|
|
|
|
The title still seems to only have a get and not a set type (see here[^]).
The only way to set this appears to be via the xaml itelf.
This property does not appear to be a Dependency Property so binding too seems out of the question.
I may be wrong though.
|
|
|
|