For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I have a Path that I create at runtime and show it on a custom control. This part works perfect. The visual tree is simple:
UseLayoutRound=True, SnapToDevicePixels=True. Line is a 1 pixel tall horizontal line and the user can customize the vertical position.
I need to stroke the path in two different colors. One color for above the line and one color for below the line. Typical solution I see is to use a 2 color brush. However, as you might suspect, it is *EXTREMELY CRITICAL* visually that the color change happen *EXACTLY* on the horizontal line. +/- 1 pixel is not acceptable.
The problem I'm having seems to be to align the color change on the line 100% of the time. For example, if my control is 99 pixels high and the threshold is at 50%, I should have 49 + 1 + 49.
I have tried the following solutions… problems I encountered are listed as well. Any way to get this working perfectly 100% of the time?
1) Vertical LinearGradientBrush
Generally works and hits the line 100% of the time, but it doesn’t give me a hard break between the two colors, so for example black going into white will leave a gray line
2a) DrawingBrush with RectangleGeometries
2b) DrawingBrush with DrawingContext
Both of these ideas have the same problem. I can’t hit the line 100% of the time (round off errors I’m guessing…) but I’m using the same math as with #1, so…
I can get a hard color change with both these, but I get +/- 1 pixel off errors…
My first thought would be to draw the line twice.
Once as a TWO pixel tall line in one color,
then again as a ONE pixel tall line in the other color, overwriting half of the line.
I don't know how accurately this would work...
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
The problem seems to be that DrawingBrush has round-off errors internally or it doesn't work the same way as the LinearGradientBrush in terms of origin / relative ratios. Like I said, LinearGradientBrush hits the line consistently with my "math". DrawingBrush isn't even consistent at 50% which should not even be suspectible to round-off errors since its a whole pixel. Sometimes its 1 pixel too high, sometimes its 1 pixel too low. Also tried TransformToVisual to go from the line to the path, but TransformToVisual considers both shapes to be the same height (as the height of the control), so it just maps the points 1 to 1. Tried Math.Round() and Math.Ceiling(), etc. LOL. The line itself certainly doesn't move around, its always at the exact correct location. Tried get the rendered bounds of the path and calculating it from that, but same thing... +/- 1 issues. Also tried setting everything to absolute mode and setting the rectangles identically, nope... Maybe the LinearGradientBrush only *appears* to be working and is hiding the +/- 1 issues with the gradiented color switch.
Argument 1: cannot convert from 'System.Windows.RoutedEventHandler' to 'System.Windows.RoutedEvent'
The best overloaded method match for'System.Windows.FrameworkElementFactory.AddHandler(System.Windows.RoutedEvent, System.Delegate)' has some invalid arguments
The event'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl.AssignmentRemoved' can only appear on the left hand side of += or -= (except when used from within the type 'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl')
I don't understand what's going on here. What's the right way to wire up my event?
Why doesn't this work? If you zoom in on the image at runtime, you'll notice that the top is red and the bottom is green, but at the transition between them, there is a dark line. It's my understanding that if you use the same offset for two colors, you'll get a hard break.
By my math, 0.611111111111111 * 18 = 11, so its not like I'm giving it half pixels or anything. If I use .5 / .5 for the offsets, I get a hard break.
I have 3 tables which are linked to each other with Primary and Foreign key relationship. When I use the datasource combinely for all the 3 tables unable to edit the records and Add option is not visible. What should be the resoultion
I normally Google for this kind of stuff, but I'm not sure of the proper name / terminology since I'm not really a math guy, so I'm not coming up with any hits...
I'm trying to draw a very simple "graph". 0,0 10,10 20,3 30,15, etc.
So, right now, I just add the points to a PolyLine and all is good.
But this results in a sharp zig-zag line... how do I make it into a "smoother" "wave" type line based on the same point array? The only term I remember from math class is bezier curves lol, but that doesn't seem to be what I'm looking for.
Hmm... I found some Petzold code that creates a canonical spline in WPF, seems like its working (doing what I want) unless I don't know what I'm talking about which is entirely possible since I don't know the diffs between all those splines haha. All I know is that it looks like a wave interpertation of my zig-zag line. Thanks!
I've got a WPF TreeView that is using the structure in Josh Smith's article[^]
In my case I've only got one type of object (Unit) that has a self-referencing hierarchy. So I only have one item ViewModel and so only the one HierarchicalDataTemplate.
Everything 'works', but there are two usability issues:
1) clicking on the expander can take a while, and there's nothing to indicate to the user that its happening.
2) the expanders appear on items that have no children (I assume due to the DummyChild that gets added.
For the 1st issue, I added a INPC property IsLoading to the base item VM TreeViewItemViewModel. Then I've been round and round in circles trying to get this working...at the moment I've got...
In my UnitTreeItemViewModel in the LoadChildren override I set IsLoading before and after.
IsLoading = true;
//sim a delay
foreach (Unit u in UnitCache.Units.AllUnits.Where(WhereClause))
base.Children.Add(new UnitTreeItemViewModel(u, this, _uh));
IsLoading = false;
Finally I added a simple TextBlock that I make visible based on IsLoading:
But all this does is show on the child items (after they appear), not the parent
I've tried changing it to set the Parent's IsLoading, but that didn't seem to work either, the root items don't have Parents for a start...
I have a wpf window which is a splash screen. I want it to be displayed for a certain time interval (say 5 sec) and then it closes and new login window opens.the problem is that in splash screen there are some process undergoing so if i call sleep() they stop working and mouse pointer shows busy symbol.
If I have an xml document of books, like:
<Title>WPF For The Hard-of-Learning</Title><Category>N</Category></Book></Books>
and an xml document of book categories:
is there a way to bind the element value from the second document that is associated with an element in the first document?
To clarify using the above xml document examples, I'd like to display the book title and its category name (Non-Fiction), not its Category code (N).
In a code-behind file I'd like to load into XmlDocument objects the xml from a file that holds the Books xml and from a file that holds the Categories xml. In the code-behind I would assign the xml documents as the Document property of a couple XmlDataProviders defined in the XAML.
In your code behind, should be ViewModel, create a class, a Model, with the Book properties and add an additional property for the Category. Insert the records from the Book xml and update the item with the Category details.
This is the normal process of creating a model to match the UI requirements. Your UI will often not match the database structure, that is why there are such concepts as DAL, Mode, View, ViewModel.
Never underestimate the power of human stupidity
Hi all ,
I need to create add in project in silver-light mvvm project , i'm complete new to create add in projects please help me .i checked in online and i found one project from this site .but it is working for only visual studio . I need to work for my project . please help me ...
Visual Studio is and IDE, Integrated Development Environment, your project and the article you found are BOTH built on VS, the article is just another project built by a developer. How you can call yourself a "Senior" developer in your profile baffles me!
Do some research into MEF[^]. However I would suggest you need to do some more basic reading before tackling MEF!
Never underestimate the power of human stupidity
Hello Mycroft Holmes ,
Thank you for your response , yes i was downloaded the sample project and try to understanding how that is implemented (this is not use for me but it will give some idea how to start,so that i downloaded.) Frankly i don't know how to create a add in project. I thought some one will give idea how start while posting this question but, i got different answer. please have any idea help me still if you think this is useless question just ignore this .