Select to view content in your preferred language

Map Printing Sample with text

868
5
Jump to solution
02-06-2012 01:31 PM
ChrisBradberry
Deactivated User
Hey,

Another question about the map printing sample.  I have looked through the forums, but I did not see this topic.  I am using the functionality from the "withtext" template in my printing.  My issue is that I am trying to make the text dynamic, depending on an identify function.  Now the text will only update on the initial load of the print dialog, so when I make multiple maps, the text stays the same for each map. 

Does anybody know which event I could use, or some other way to dynamically update a textblock on the template?

thanks, Chris
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
Dominique,

I tried that, but this only fires on load. I put a breakpoint in the sample and it only fired when the dialog loaded. Is there a way to catch the extent change on the map in the dialog?

Chris

It's fired every time the page changes.
But I probably misunderstood your issue. I thought your were printing multi pages and that you wanted to change some info by page.

If you want to change the text info in your unique printed page, just changing the property should do the trick:

mapPrinter.DataItems["MyIdentifyResult"] = MyIdentifyResult(); 

Then it's just a matter of binding.

View solution in original post

0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
One option is to hook up an handler to the PageChanged event of your mapPrinter.
In this handler, you can change the value of your textblock (or more likely, change a property which is binded to your textblock).

To do that, you can use the MapPrinter.DataItems dictionary which is done to add custom infos to the print page.

Something like:
private void mapPrinter_PageChanged(object sender, PageChangedEventArgs e)
{
    var mapPrinter = sender as MapPrinter;
    if (mapPrinter != null)
    {
        mapPrinter.DataItems["MyIdentifyResult"] = MyIdentifyResultFromPage(e.Page); // MyIdentifyResultFromPage to write depending on your context
    }
}


Then in your print page template you can use this DataItem this way:
<TextBlock TextWrapping="Wrap"
   Text="{Binding DataItems[MyIdentifyResult], RelativeSource={RelativeSource TemplatedParent}}"/>
0 Kudos
ChrisBradberry
Deactivated User
Dominique,

I tried that, but this only fires on load.  I put a breakpoint in the sample and it only fired when the dialog loaded.  Is there a way to catch the extent change on the map in the dialog?

Chris
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Dominique,

I tried that, but this only fires on load. I put a breakpoint in the sample and it only fired when the dialog loaded. Is there a way to catch the extent change on the map in the dialog?

Chris

It's fired every time the page changes.
But I probably misunderstood your issue. I thought your were printing multi pages and that you wanted to change some info by page.

If you want to change the text info in your unique printed page, just changing the property should do the trick:

mapPrinter.DataItems["MyIdentifyResult"] = MyIdentifyResult(); 

Then it's just a matter of binding.
0 Kudos
ChrisBradberry
Deactivated User
Dominique,

I am mainly interested in unique maps. Where do I put that code to have it fire with the extent change?  The page_changed does not seem to fire with extent change.

Chris
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Dominique,

I am mainly interested in unique maps. Where do I put that code to have it fire with the extent change?

At first glance, I would say in an handler hooked up to the Map.ExtentChanged event.:)
I guess too easy answer, there is probably something, I didn't get in your issue.


You have to set the property that is displayed in the print page as soon as its value changes but that's depending on your context.

For example, if you want to display a text with the current extent, you can set this property on Map.ExtentChanged event.

If you want to display a result from an identify task (I thought it was your case from your first posts), set the property as soon as you get the identify result...

Note : Perhaps the problem is coming that there are 2 maps, one main map in your application and one map used for the printing. You can hook up an handler to this second map by code like : mapPrinter.PrintMap.ExtentChanged += .....
0 Kudos