I have a FlowDocumentPageViewer control that I am populating from the code behind. I am adding text from 3-4 items. I need to know on what page item 1,2,3... ends.
These items get added to a FlowDocument in a loop and then at the end I have
flowDocumentPageViewer.Document = resultsDocument;
However, even then if I call
flowDocumentPageViewer.PageCount
I still get 0. If I do some event like a click and print the above PageCount after the window renders, it does print the correct value. However, I need a running total of this value as I populate the FlowDocument. I am hoping someone knows some kind of trick with text metrics or any other way that this could be solved.
You have no choice but to trigger a (virtual) render of your control to get this kind of info.
the easiest way is to force a updateLayout() on the FlowDocumentPageViewer, but this means it'll show the result before you get the info which is probably not what you want.
you can also use the Arrange() method if you don't want the content to be shown:
http://msdn.microsoft.com/en-us/library/system.windows.uielement.arrange.aspx
after using this on your control you should get the updated info.
I had the same problem and to be honest I still do. Any updateLayout() did not help. Now I use a timer to get the pagecount a second later after I assigend to document to the viewer. Works fine.
Related
I am trying to use simple example code I've found in Google.
Everything works except as soon as I set the delegate for the column, it's displaying gets buggy.
Here are the line where I set the "Bank" string as a value for both rows and comboboxdelegate.cpp
Here's a screenshot of MainWindow
The question is, if the data is stored in model, why is it not displayed properly? Because if I change the value using combobox, what is displayed in cell still stays as shown in screenshot. However pressing button shows that data in model has been changed
P.S. I am not concerned about editor not being persistently visible, I'm concerned about displayed cell value being something else.
I had to change the line QString text = items[index.row()].c_str() to index.data(Qt::DisplayRole).toString().
So while painting the delegate Qt will access data stored in model, not in delegate's option vector
I also had to change model->setData(index, _editor->currentIndex()); to model->setData(index, _editor->currentText());
Currently I am stuck with a problem that is simple on the first sight. Its about automated GUI testing.
I want to make a row/cell of a WPF DatGrid completely visible by scrolling using ScrollIntoView(row) and then accessing the row/cell directly after. Unfortunately scrolling in ScrollViewer seems to happen asynchronously. This means I need to wait for the scrolling to finish before accessing the row/cell. For this purpose I found the ScrollChanged event I can subscribe.
There is only one detail I can not solve: If the row/cell I want to access is already visible (and no scrolling is necessary) I do not get that event and the algorithm gets stuck. I was not able to find a reliable way to predict if a call to ScrollIntoView(row) actually scrolls.
Any idea how to solve this?
To make sure layout is updated call UIElement.UpdateLayout after you ScrollIntoView and before you want to use item. Quoting MSDN it
Ensures that all visual child elements of this element are properly updated for layout.
I have googled, searched forums and stack exchange but nothing seems to work for me. I am running extJS 3.2.1.
Basically I have a gridpanel control which has items that are greyed out as they are completed but the vertical view pane is only about 200 px while the list can grow quite large leaving users to scroll down each time I do a store.reload()
I have discovered I can manually move the next item in the list by calling:
grid.getView().getRow(15).scrollIntoView();
I cannot use selectRow() because I have enabled the checkboxes instead of row selection.
Anyway the above code works great only I cannot determine "where" to call it. I have tried capturing the store.load event as well as the grid.afterrender and neither seem to work.
Any ideas?
If you go to the source of store.reload(); you can see it calls the the load method.
http://docs.sencha.com/ext-js/3-4/source/Store.html#Ext-data-Store-method-reload
So you really should be hooking the load event.
Something like
store.on('load',function(){
grid.getView().getRow(15).scrollIntoView();
})
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.grid.CellSelectionModel-method-select
is the cell selection model equivalent btw ( of row select ).
I am using a standard TreeView in a WinForms application and everything works fine except for one issue:
Parts of the system need to change depending on the selected TreeNode, which works fine using the AfterSelect event.
However, sometimes the TreeView will get cleared completely resulting in an empty selection which does not trigger this event.
At the momemnt I am calling the event callback manually to fix this issue.
This is obviously dangerous, since I will forget to call this function somewhere. Is there a "correct" way to do this?
Thank You!
This is by design. The underlying native Windows controls only generate notifications for things you cannot figure out yourself. The ListBox control for example doesn't have any event that tells you an item got added or removed. Which is because there is no way for the user to add or remove items. Similarly, there's no way for the user to remove the nodes from a tree view.
These kinds of changes requires code that you write. Since it is your code, you cannot not know that these changes happened. If you want an event then you'll have to raise it yourself. Beware that this is harder than it looks, the TreeNodeCollection class doesn't reliably let you generate an event for programmatic changes to the node collection. It doesn't behave like an ObservableCollection. You are definitely better off by not needing this event.
I have a WPF Window loaded. But on event of sizeChanged, it fires twice. May I know why?
Also, I have tried adding 'e.handled = true'
Yeah, I've noticed the same thing. If you look at the value for e.NewSize you'll see they are different values, with the final time being the correct size. It must be something in the way it gets laid out.