Click here to Skip to main content
15,903,362 members
Home / Discussions / WPF
   

WPF

 
QuestionHow to handle Refresh and Reset in WPF application in MVP application [modified] Pin
Krishna Aditya7-Sep-09 6:03
Krishna Aditya7-Sep-09 6:03 
QuestionChanging text from white to black for printing Pin
DavidRen236-Sep-09 23:10
DavidRen236-Sep-09 23:10 
AnswerRe: Changing text from white to black for printing Pin
Richard MacCutchan7-Sep-09 0:43
mveRichard MacCutchan7-Sep-09 0:43 
GeneralRe: Changing text from white to black for printing Pin
DavidRen237-Sep-09 0:59
DavidRen237-Sep-09 0:59 
GeneralRe: Changing text from white to black for printing Pin
Richard MacCutchan7-Sep-09 1:36
mveRichard MacCutchan7-Sep-09 1:36 
GeneralRe: Changing text from white to black for printing Pin
DavidRen237-Sep-09 3:30
DavidRen237-Sep-09 3:30 
GeneralRe: Changing text from white to black for printing Pin
Richard MacCutchan7-Sep-09 5:01
mveRichard MacCutchan7-Sep-09 5:01 
QuestionWPF Unit Test Problem Pin
Hauke Wittern6-Sep-09 22:59
Hauke Wittern6-Sep-09 22:59 
Hello,

I have a problem writing a unit test for a algorithm that calculates the position of some controls. The problem is that some assertions fail because setting a property does not immediately update all other Properties that depend on its value.
For example the following assertion fails (Button.Width is a DependencyProperty):
button.Width = 123;
Assert.AreEqual(123, button.ActualWidth);


This assertion fails because the layout is not immediately updated by the WPF after setting the Width Property.

My concrete scenario looks like this:
1. Set up the test with a window with some child controls
2. Simulate moving a item by the user (done with an associated AutomationPeer and a Move Method). This affects the Center property and implicitly the ActualCenter property of the item.
3. Call the Layout Algorithm that I want to test. In order to calculate the bounds of the items the Layout Algorithm uses Properties like ActualWidth, ActualHeight and ActualCenter as well as the FrameworkElement.TransformToVisual() method.
4. execute assertions that test if the Layout Algorithm works correctly.

[TestMethod()]
public void LayoutTest()
{
    // simulate user input
    ItemPeer1.Move(50, 100);

    // execute the tested method
    LayoutAlgorithm.Layout(TheScatterView); // modifies the center of some items (in this case item2 should be updated)

    // test if the layout algorithm works correctly
    Assert.AreEqual(new Point(50, 100), Item1.Center); // using ActualCenter would fail
    Assert.AreEqual(new Point(200, 100), Item2.Center); // fails.
    // ...
}


The assertions in step 4 fail because the layout algorithm (step 3) gets obsolete information about the center of the moved item. May be the algorithm works correct but I cannot test it.

How can I get this Unit Test working? Do I have to force WPF to update the layout? How?
A solution for the first example with the button might be sufficient to help me:

button.Width = 123;
DoSomethingSoThatActualWidthGetsUpdated(); // what to do here?
Assert.AreEqual(123, button.ActualWidth);

QuestionImages upload to SQL database Pin
Nekkantidivya6-Sep-09 22:06
Nekkantidivya6-Sep-09 22:06 
AnswerRe: Images upload to SQL database Pin
Arun Jacob6-Sep-09 22:19
Arun Jacob6-Sep-09 22:19 
AnswerRe: Images upload to SQL database Pin
Elayaraja Sambasivam7-Sep-09 2:28
Elayaraja Sambasivam7-Sep-09 2:28 
QuestionCatastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Pin
Nekkantidivya6-Sep-09 21:57
Nekkantidivya6-Sep-09 21:57 
AnswerRe: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Pin
Elayaraja Sambasivam7-Sep-09 2:38
Elayaraja Sambasivam7-Sep-09 2:38 
GeneralRe: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Pin
almog.ori27-Jul-10 22:47
almog.ori27-Jul-10 22:47 
AnswerRe: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) Pin
Vimalsoft(Pty) Ltd26-May-11 0:30
professionalVimalsoft(Pty) Ltd26-May-11 0:30 
Questionbeginsavechanges help Pin
LT9996-Sep-09 21:06
LT9996-Sep-09 21:06 
QuestionStyling an AdornerLayer Pin
Etienne_1235-Sep-09 2:39
Etienne_1235-Sep-09 2:39 
AnswerRe: Styling an AdornerLayer Pin
Pete O'Hanlon5-Sep-09 3:15
mvePete O'Hanlon5-Sep-09 3:15 
Question3D model as Splash Pin
Etienne_1235-Sep-09 2:27
Etienne_1235-Sep-09 2:27 
AnswerRe: 3D model as Splash Pin
Pete O'Hanlon5-Sep-09 3:11
mvePete O'Hanlon5-Sep-09 3:11 
QuestionListView Expands Height But Doesn't Contract It Pin
AspDotNetDev4-Sep-09 13:37
protectorAspDotNetDev4-Sep-09 13:37 
GeneralWhy Does It Do That? [moved] Pin
#realJSOP4-Sep-09 0:07
professional#realJSOP4-Sep-09 0:07 
GeneralRe: Why Does It Do That? Pin
peterchen4-Sep-09 0:12
peterchen4-Sep-09 0:12 
GeneralRe: Why Does It Do That? Pin
#realJSOP4-Sep-09 0:26
professional#realJSOP4-Sep-09 0:26 
GeneralRe: Why Does It Do That? Pin
Rajesh R Subramanian4-Sep-09 0:48
professionalRajesh R Subramanian4-Sep-09 0:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.