|
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.
|
|
|
|
|
Thanks for the hint. I tried the WindowSettings.Title but as you have pointed out, it is only accesible via XAML Attribute Usage and is not settable in code-behind or usable via data binding.
I think I've found another solution:
Im accessing the Main Application Window via "Application.Current.MainWindow" (see here[^]). This Application Class Property is of the Type System.Windows.Window (see here[^]) which has a settable Property "Title". Now I can at least set the main window title during runtime via a method:
private void SetMainTitle(string TitleStr)
{
if (string.IsNullOrEmpty(TitleStr))
{
}
else
{
Application.Current.MainWindow.Title = TitleStr;
}
}
|
|
|
|
|
I am trying to manke a generic HierarchicalDataTemplate to be used in all TreeViews. I am creating a Templates.xaml where I have the following template
<!--
<HierarchicalDataTemplate x:Key="TreeNodeTemplate" DataType="{x:Type vm:TreeNodeVM}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0"
Source="{Binding ImageSource, Converter={StaticResource ImageFromAssetsConverter}}" /><<<< error here
<TextBlock Text="{Binding NodeLabel}" Margin="3" />
</StackPanel>
</HierarchicalDataTemplate>
My problem is that I cannot work out how to reference the Converter ImageFromAssetsConverter which lives in the Code folder. I have declared the code folder in the .xaml header.
xmlns:code="clr-namespace:ClassBuilder.Code">
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
First of all, if this template can be used across projects, you have to specify which assembly i<t is in as well. The problem you look to be having is that you haven't supplied the ImageFromAssetsConverter key. This would look something like
<code:ImageFromAssetsConverter x:key="ImageFromAssetsConverter" />
|
|
|
|
|
Pete O'Hanlon wrote: First of all, if this template can be used across projects
Bloody hell I just want to get the dammed thing working in my POC, I'm happy to make it project specific and C&P it from one project to the next as it is still evolving.
I have the reference in my App.xaml and the template works fine when placed inside the TreeView on the view.
<!--
<ResourceDictionary>
<code:ImageFromAssetsConverter x:Key="ImageFromAssetsConverter" />
</ResourceDictionary>
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The key should be defined in Templates.xaml rather than App.xaml. Just move that line into your template file and you should be good to go.
|
|
|
|