How can I specify programmatically the position of a new grid (created programmatically, see below) within a FlowDocumt I have already created via XAML. I want the new grid to show below another Grid I already have in the FlowDocument.
Dim myItemsGrid As Windows.Controls.Grid = New Windows.Controls.Grid
Apparently, there is no way.
The way to go is to use Tables, as this are more compatible with FlowDocuments any way. The flow document pagination does not truncate grid content as it should, tables however work nicely.
Related
I am looking for a layout control or other means of laying out data in a tabular format on a Fixed Document for reporting. I have used MigraDoc quite extensively in non WPF projects and its table object allows for a granular layout for each piece of data to be displayed in the table. Borders can be turned off on the cell level, columns can be merged/spanned, etc. Are there any controls that offer this kind on control within WPF? I have not seen where the DataGrid or the Grid will do what I need... easily. My data is not bound as I need to have full control over how it is displayed. I am not using a flow document so I cannot use the table object that it offers. Anyone have any suggestions? For now, I have resorted to programmatically creating a Grid and then inserting a Border containing a TextBlock within each cell. There just has to be a cleaner way!
BTW - I am looking to use native WPF controls in this project which is the reason that I am not using MigraDoc.
I have a WPF window that contains three items controls, along with 3 buttons. Is there any way using PrintVisual() that I can print just two of the items controls, and no buttons?
My first thought was to dynamically create a StackPanel and add the controls that I wanted to print to it, but I can't do that without detaching them first and it seems problematic.
I would like to use PrintVisual because it's so simple. (Unfortunately I can't spend too much time on this application).
***Please forgive the lack of source code supplied, but I'm relatively new to WPF and currently my form is grotesquely over-coded. I guess I'm just curious if there is a simple solution out there.
Thanks.
If your concern is only printing a part of the page. Place your two items controls that you want to print inside a Grid element. Give it a name
<Grid x:Name="printGrid">
....
</Grid>
Then you can call PrintDialog.PrintVisual like
PrintDialog printDialog = new PrintDialog();
printDialog.PrintVisual(printGrid,"The Description");
If you cannot manage to group only those controls into their own grid you could do it manually by creating a Container in code and adding your existing named itemsControls to them. Then you can PrintVisual the container.
In my gridview I need to aggregate subrows into each row, something like in p2p emule/amule application where you can do double click to each file you are downloading and then under it you can see the parts of the file from where you are downloading.
Is it possible in WPF?
Thanks.
You could do a few things:
Add some container (ie: another Grid or a StackPanel) to the Grid row. This would let you add multiple objects to the grid row. On your "double click" event, you could change the visibility to show those objects.
Use a TreeView with a HierarchicalDataTemplate, and treat this as hierarchical data. This is most likely the more "correct" approach. The Displaying Hierarchical Data sample on MSDN walks through the process of this.
I'm not quite sure how to go about this so any advice would be much appreciated.
I have a ListView whose default implementation is using with column headers. At runtime in the program I would like to be able to click on a button at runtime to change the view so that the list view loses the GridViewColumn headers and implements a new style using one of my own data template.
Then I would also like the ability to click the button and change the ListView back to a grid view with column headers.
Can anyone point me in the correct direction of how to go about this?
Thanks
Since ListView.View is dependency property, you can bind it to something on your VM via converter.
Microsoft has a sample that demonstrate how to create a ListView control that displays data in multiple view modes, which include the GridView and other custom view modes.
Search for ListView with Multiple Views Sample in the WPF Documentation Sample page.
http://archive.msdn.microsoft.com/wpfsamples
Here is a direct link to download the sample:
http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=wpfsamples&DownloadId=7766
I'm using the WPF DataGrid, and I'd like to know if there is any way I can access the DataGridRow's RowDetails programatically.
For example, when the user selects the row, I'd to grab some data from somewhere (say, a database), and display it in the RowDetails.
All of the examples I've seen tend to just display some extra bound data that isn't included in the columns for the row.
You could display some extra data but lazy-load it on SelectionChanged.
It usually is not easy to work directly with the WPF controls, they are not really meant to be used without a backing databound model.
If you have all the data in list of objects (or something similar) then you can do all sorts of fun things. I'm using a WPF Datagrid in this manner, and when a user selects a row, I think populate an editor control above the grid with the row item plus additional details.
That said, there's nothing stopping you from adding in additional information in the grid that's normally hidden and a trigger on row selection to show the additional data
you can use the following code
DataRowView row = (DataRowView)MyDataGrid.SelectedItem;
string strName = row.Row["Name"].ToString(); //where "Name" is the column name