Problem with WPF perfomance - wpf

I have form which has many tabs. Every tab has many controls textboxes, comboboxes, datagrids and e .t.c. I bind form to one data source in such way
this.DataContext=MyClassInstance
But with this way my form opening very slow. about one minute.
When I comment above code, form opens very quickly. All My controls I bound to the class properties in XAML. Please tell me the way to bind every tab when it's activated, or bind controls in background thread or any other idea which can help me to speed up my form.
Thanks in advance.

I think the problem lies in your class instance you are binding to.
When the xaml is bound to the class, all the getters of the bound properties are fired. If each getter accesses the database to get some data, this can take a while.
I think you should really review your design here, and think about asynchronously fetching your data.

I agree with Gerrie.
I'm suggesting the following:
When you start your application, you automatically open one tab i guess. Load only that tab, don't care about the others. This should start your project much faster.
The thing you do for the other tabs is load them when clicked for the first time. When the user for example is interested in tab 5, the only ones loading will be the initial tab at startup, and tab 5 when clicked by the user. all other tabs will not be loaded, which will decrease startup time.
Hope the idea is clear to you and will help your application.

I found why my form open so slow. I use about 20 XMLDataProvider object in form. and this providers were iteract with xml file. When I comment code below everything working fast. Thank everyone for help
//relatives_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RelativeList" };
//education_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_EducationList" };
//requalification_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RequalificationList" };
//jobHistory_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_JobHistoryList" };
//rank_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RankList" };
//tradeUnion_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_TradeUnionList" };
//election_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_ElectionList" };
//judgeHistory_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_JudgeHistoryList" };
//tempWork_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_TempWorkList" };
//inquire_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_InquireList" };
//bulleten_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_BulletenList" };
//reprimand_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_ReprimandList" };
//certificate_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_CertificateList" };
//course_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_CourceList" };
//incentive_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_IncentiveList" };
//btrip_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_BtripList" };
//vacation_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_VacationList" };
//pass_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_PassList" };
//language_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_LanguageList" };

Related

Visual Relations using Winium automating a WPF app

Using other automation tools for Windows Apps, such as LeanFT, there is a way to specify a visual relation. For example, if I identified a label, I could then say look for the text box to the right of it.
Is there a way to do this in Winium?
Here is a sample of what the code looks like in LeanFT
var projectButton = baseOR.PlatformWindow.ProjectList.BrowseProjects.Describe<IButton>(new ButtonDescription
{
FullType = "button",
Text = node,
Index = 0
});
return baseOR.PlatformWindow.ProjectList.BrowseProjects.Describe<IButton>(new ButtonDescription
{
FullType = "button",
Vri =
{
new VisualRelation
{
TestObject = projectButton,
HorizontalRelation = HorizontalVisualRelation.LeftAndInline,
}
}
});
As you can see, we are essentially identifying one element, and then using that as the TestObject in the VisualRelation to identify something else.

Adding Entity into its own block in DraftJS

So I'm trying to create a fairly simple WYSIWYG BBCode editor for my project as an opportunity to wrap my mind around DraftJS. I've been following some tutorials and also using react-rte as an example (since it has 99% of the functionality I need and looks relatively simple to understand).
The problem I've stumped on is that react-rte inserts image entities inline (it adds a space in the current selection and then ties an entry to that space) like this:
const addEntity = (editorState, type, mutability = 'MUTABLE', data = {}) => {
let currentContent = editorState.getCurrentContent();
let selection = editorState.getSelection();
currentContent = currentContent.createEntity(type, mutability, data);
let entityKey = currentContent.getLastCreatedEntityKey();
return Modifier.insertText(currentContent, selection, ' ', null, entityKey);
}
I want each image (and video alike) to be in its own separate block and make it so nothing else can be written to that block.
I have found an example of the behavior I'm after in megadraft, but I have been unable to work my way through its code to find the correct implementation.
Found the solution after many hours of trial and error (and lots of manuals).
const addAtomic = (editorState, type, mutability = 'MUTABLE', data = {}) => {
let currentContent = editorState.getCurrentContent();
let selection = editorState.getSelection();
currentContent = currentContent.createEntity(type, mutability, data);
let entityKey = currentContent.getLastCreatedEntityKey();
const newState = EditorState.set(editorState, { currentContent: currentContent })
return AtomicBlockUtils.insertAtomicBlock(newState, entityKey, ' ')
}

How to get Selected Listbox Items using devexpress in winforms app?

I am trying to get selected item text. I used this below code
MessageBox.Show(listBoxColumnHeaders.SelectedItems);
Output
Devexpress.XtraEditors.BaseListboxControl+SelectedItemCollection
But my text is Country
Update
I add listbox items from another class. That class called FilterColumnHeader using below code
FilterControl fc = Application.OpenForms.OfType<FilterControl>().SingleOrDefault();
List<FilterColumnHeader> headers = new List<FilterColumnHeader>();
while (rd.Read())
{
headers.Add(new FilterColumnHeader { typeOfHeader = rd["type"].ToString(), columnHeadersName = rd["AsHeading"].ToString() });
}
fc.listBoxColumnHeaders.DisplayMember = "columnHeadersName";
fc.listBoxColumnHeaders.ValueMember = "typeOfHeader";
fc.listBoxColumnHeaders.DataSource = headers;
Now When I try to print using this below code,
MessageBox.Show(""+ listBoxColumnHeaders.SelectedItems[0].ToString());
It is showing in message box like below
`ProjectName.FilterColumnHeader`
The SelectedItems property returns a collection of selected objects. All you need to do is to cast the required object to your type:
var filterColumnHeader = (FilterColumnHeader)listBoxControl.SelectedItems[0];
I don't know if you found an answer but this works for me :
StringBuilder list = new StringBuilder();
foreach(var item in listBoxColumnHeaders.SelectedItems)
{
list.AppendLine(item as string);
}
MessageBox.Show(list.ToString());

How to programmatically add a LinkItem to a LinkItemCollection

I know the question sounds simple but it's actually tricky.
We have a page (CoursePage) that is cloned first before setting its properties at runtime.
PageData clone = existingCoursePage.CreateWritableClone();
coursePage = (CoursePage)clone;
// set properties....
// RelevantCourseInformationCollection is a LinkItemCollection
coursePage.RelevantCourseInformationCollection.Add(new LinkItem { Href = "google.com", Text = "Google" });
and I'm getting a null LinkItemCollection.
It seems likely that your existing page does not currently have any items in the RelevantCourseInformationColletion. If this is the case, the property will be null and you will have to assign it a new LinkItemCollection instance before trying to add any LinkItems.
coursePage.RelevantCourseInformationCollection = new LinkItemCollection();
coursePage.RelevantCourseInformationCollection.Add(new LinkItem { Href = "google.com", Text = "Google" });
Or if you prefer the shorthand:
coursePage.RelevantCourseInformationCollection = new LinkItemColletion { { new LinkItem { Href = "google.com", Text = "Google" } } };

comments module in dotnetnuke

Is there any comments module in Dotnetnuke that can work with the journal module? I mean, if a user comments on a page, the journal module on his profile displays that this user has commented on this page? Or, could there be an item having a link to that page? Just like we have in facebook? I hope you understand my question.
There is no such module. You would have to write your own
This is some sample code from the upcoming Announcements module:
public static void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId)
{
JournalItem item2 = new JournalItem
{
PortalId = announcement.PortalID,
ProfileId = announcement.LastModifiedByUserID,
UserId = announcement.LastModifiedByUserID,
ContentItemId = announcement.ContentItemID,
Title = announcement.Title
};
ItemData data = new ItemData
{
Url = announcement.Permalink()
};
item2.ItemData = data;
item2.Summary = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "...");
item2.Body = null;
item2.JournalTypeId = 33;
item2.SecuritySet = "E,";
JournalItem journalItem = item2;
JournalController.Instance.SaveJournalItem(journalItem, tabId);
}
Important to note: you need to define your own JournalType (in the sample above, this is not fully implemented yet, and using a hard coded value of 33). Basically, what you need is a new record in the JournalTypes table, defining your own journalType

Resources