मैं एक ऐसे एप्लिकेशन का परीक्षण करना चाहता हूं जो डेटा फ़ील्ड मान के साथ टेक्स्ट ब्लॉक प्रस्तुत करता हो। प्रतिपादन पूरा होने के बाद, मैं वास्तविक चौड़ाई और वास्तविक ऊंचाई प्राप्त करना चाहता हूं। सब कुछ ठीक काम करता है। जब मैंने एप्लिकेशन का परीक्षण करने की कोशिश की तो समस्या पहली बार आई। मैं टेस्ट प्रोजेक्ट से प्रेषक को आमंत्रित करने में असमर्थ हूं।नुनिट में डब्ल्यूपीएफ डिस्पैचर का आह्वान कैसे करें?
कोड निम्नलिखित है।
this.Loaded += (s, e) =>
{
TextBlock textBlock1 = new TextBlock();
//// Text block value is assigned from data base field.
textBlock1.Text = strValueFromDataBaseField;
//// Setting the wrap behavior.
textBlock1.TextWrapping = TextWrapping.WrapWithOverflow;
//// Adding the text block to the layout canvas.
this.layoutCanvas.Children.Add(textBlock1);
this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
(Action)(() =>
{
//// After rendering the text block with the data base field value. Measuring the actual width and height.
this.TextBlockActualWidth = textBlock1.ActualWidth;
this.TextBlockActualHeight = textBlock1.ActualHeight;
//// Other calculations based on the actual widht and actual height.
}
));
};
मैंने अभी एनयूनीट का उपयोग करना शुरू कर दिया है। तो, कृपया मेरी मदद करो।
धन्यवाद
करने की कोशिश कर रहे हैं, ठीक उसी तरह, जो मैं ढूंढ रहा था। धन्यवाद स्टीवन महान :) –