<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infragistics.com/community/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Silverlight</title><link>https://www.infragistics.com/community/product_platforms/silverlight/</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 10 Non-Production</generator><item><title>Wiki Page: Extension Methods for Navigating the xamDataChart</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/56/extension-methods-for-navigating-the-xamdatachart</link><pubDate>Wed, 20 Feb 2019 17:37:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:dd7518db-75a2-4a6c-ad3a-d2cd46d5413d</guid><dc:creator>Jason Zajac</dc:creator><description>I recently posted a video demonstrating how to implement some extension methods to support xamDataChart navigation. The navigation support implemented in the demo included: PanUp PanDown PanLeft PanRight ZoomIn ZoomOut FitInWindow The only problem with the code I used in the video, was that the event handler for the buttons included a long if statement to handle navigation support. As the famous quote goes, “If it smells, it’s bad code”, so I wanted to refactor the implementation to be a bit more maintainable. Before I get into the changes, I first want to list the extension methods that I implemented in order to make it easy to pan and zoom the chart. Notice that the methods us a default scale value so you are not required to pass in a scale amount for each method call. public static class xamDataChartExtensions { private static double _defaultScale = 0.05; public static void ZoomIn(this XamDataChart dataChart) { ZoomIn(dataChart, _defaultScale); } public static void ZoomIn(this XamDataChart dataChart, double scale) { dataChart.WindowScaleHorizontal -= scale; dataChart.WindowScaleVertical -= scale; } public static void ZoomOut(this XamDataChart dataChart) { ZoomOut(dataChart, _defaultScale); } public static void ZoomOut(this XamDataChart dataChart, double scale) { dataChart.WindowScaleHorizontal += scale; dataChart.WindowScaleVertical += scale; } public static void PanUp(this XamDataChart dataChart) { PanUp(dataChart, _defaultScale); } public static void PanUp(this XamDataChart dataChart, double scale) { dataChart.WindowPositionVertical -= scale; } public static void PanDown(this XamDataChart dataChart) { PanDown(dataChart, _defaultScale); } public static void PanDown(this XamDataChart dataChart, double scale) { dataChart.WindowPositionVertical += scale; } public static void PanLeft(this XamDataChart dataChart) { PanLeft(dataChart, _defaultScale); } public static void PanLeft(this XamDataChart dataChart, double scale) { dataChart.WindowPositionHorizontal -= scale; } public static void PanRight(this XamDataChart dataChart) { PanRight(dataChart, _defaultScale); } public static void PanRight(this XamDataChart dataChart, double scale) { dataChart.WindowPositionHorizontal += scale; } The previous code I implemented featured a nested if statement that would call the appropriate extension method, but I knew there was an easy way to clean this code out of the page. The key to a more concise approach begins by defining a enumeration which lists the navigation options: public enum xamDataChartNavigationTypes { PanUp, PanDown, PanLeft, PanRight, ZoomIn, ZoomOut, FitInWindow, Undefined } Now armed with the navigation enumeration I added another extension method named Navigate which takes an instance of the navigation enumeration and an option to pass an explicit scale value: public static void Navigate(this XamDataChart dataChart, xamDataChartNavigationTypes navigationType) { Navigate(dataChart, navigationType, _defaultScale); } public static void Navigate(this XamDataChart dataChart, xamDataChartNavigationTypes navigationType, double scale) { switch (navigationType) { case xamDataChartNavigationTypes.FitInWindow: dataChart.WindowRect = new Rect(0, 0, 1, 1); break; case xamDataChartNavigationTypes.PanUp: dataChart.PanUp(scale); break; case xamDataChartNavigationTypes.PanDown: dataChart.PanDown(scale); break; case xamDataChartNavigationTypes.PanLeft: dataChart.PanLeft(scale); break; case xamDataChartNavigationTypes.PanRight: dataChart.PanRight(scale); break; case xamDataChartNavigationTypes.ZoomIn: dataChart.ZoomIn(scale); break; case xamDataChartNavigationTypes.ZoomOut: dataChart.ZoomOut(scale); break; default: break; } } Now as long at the Tag property of your button is equal to one of the navigation enumeration values (ex: PanUp, PanDown, etc), then the click handler is reduced to the following: private void Navigate_Click(object sender, RoutedEventArgs e) { string tag = (sender as Button).Tag.ToString(); xamDataChartNavigationTypes navigationType; if (xamDataChartNavigationTypes.TryParse(tag, out navigationType)) { this.dataChart.Navigate(navigationType); } }</description><category domain="https://www.infragistics.com/community/product_platforms/silverlight/tags/Data%2bVisualization">Data Visualization</category><category domain="https://www.infragistics.com/community/product_platforms/silverlight/tags/2010-2">2010.2</category><category domain="https://www.infragistics.com/community/product_platforms/silverlight/tags/XamDataChart">XamDataChart</category></item><item><title>Wiki Page: Silverlight</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki</link><pubDate>Fri, 01 Dec 2017 07:35:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:8a0b55a2-44c3-4d09-b482-60ea6ae039b3</guid><dc:creator>Anonymous</dc:creator><description /></item><item><title>Comment on Building the oMovies Browser: Netflix oData using Infragistics NetAdvantage Silverlight Controls</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/59/building-the-omovies-browser-netflix-odata-using-infragistics-netadvantage-silverlight-controls?CommentId=95f78ebd-c6da-4157-bd3d-546d8f4d1be8</link><pubDate>Sun, 17 Jun 2012 23:27:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:95f78ebd-c6da-4157-bd3d-546d8f4d1be8</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../card-reader.html</description></item><item><title>Comment on Styling the xamWebGrid Group By Area</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/54/styling-the-xamwebgrid-group-by-area?CommentId=4407029f-243b-47d4-a6e7-374141507034</link><pubDate>Sun, 17 Jun 2012 23:27:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:4407029f-243b-47d4-a6e7-374141507034</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../case-cover.html</description></item><item><title>Comment on Displaying AutoCAD drawings using xamWebMap</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/41/displaying-autocad-drawings-using-xamwebmap?CommentId=da774e71-e41e-438c-bf0e-e49cc4dc9750</link><pubDate>Sun, 17 Jun 2012 23:26:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:da774e71-e41e-438c-bf0e-e49cc4dc9750</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../case-cover.html</description></item><item><title>Comment on Using the VirtualCollection for Server-Side xamWebGrid Paging</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/55/using-the-virtualcollection-for-server-side-xamwebgrid-paging?CommentId=57119f4f-dac5-49b9-9a27-bb9a25b4a7e8</link><pubDate>Sun, 17 Jun 2012 23:25:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:57119f4f-dac5-49b9-9a27-bb9a25b4a7e8</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../adapter.html</description></item><item><title>Comment on Conditional Formatting With The XamWebGrid</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/43/conditional-formatting-with-the-xamwebgrid?CommentId=7938ecb7-4c47-4f31-abfd-372c0cc119f2</link><pubDate>Sun, 17 Jun 2012 23:25:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:7938ecb7-4c47-4f31-abfd-372c0cc119f2</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../adapter.html</description></item><item><title>Comment on Extension Methods for Navigating the xamDataChart</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/56/extension-methods-for-navigating-the-xamdatachart?CommentId=54f817ea-ee6f-4615-8d69-7bd8f593fc41</link><pubDate>Sun, 17 Jun 2012 23:24:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:54f817ea-ee6f-4615-8d69-7bd8f593fc41</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../charger.html</description></item><item><title>Comment on Custom Commands with Infragistics Silverlight Commanding Framework</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/35/custom-commands-with-infragistics-silverlight-commanding-framework?CommentId=5e9c6ab5-9644-4c53-b92b-aed34b66cf06</link><pubDate>Sun, 17 Jun 2012 23:24:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:5e9c6ab5-9644-4c53-b92b-aed34b66cf06</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../charger.html</description></item><item><title>Comment on faceOut - A Silverlight Reference Implementation</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/24/faceout-a-silverlight-reference-implementation?CommentId=60432e57-755d-40e3-a14e-955dbd03daed</link><pubDate>Sun, 17 Jun 2012 23:23:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:60432e57-755d-40e3-a14e-955dbd03daed</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../dock.html</description></item><item><title>Comment on Using Logarithmic Scales to Clearly Communicate Chart Data</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/23/using-logarithmic-scales-to-clearly-communicate-chart-data?CommentId=e134ad51-86df-4128-a46b-f799d699741b</link><pubDate>Sun, 17 Jun 2012 23:22:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:e134ad51-86df-4128-a46b-f799d699741b</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../dock.html</description></item><item><title>Comment on Auto-Detail Zoom with MapLayers</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/12/auto-detail-zoom-with-maplayers?CommentId=6204154d-3ba1-4fbc-adc6-84e271f5af90</link><pubDate>Sun, 17 Jun 2012 23:20:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:6204154d-3ba1-4fbc-adc6-84e271f5af90</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../screen-protectors.html</description></item><item><title>Comment on Red vs. Blue: Conditional Formatting in xamWebMap</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/36/red-vs-blue-conditional-formatting-in-xamwebmap?CommentId=987afd4a-def3-4e74-93f7-c63638cda191</link><pubDate>Sun, 17 Jun 2012 23:18:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:987afd4a-def3-4e74-93f7-c63638cda191</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../chargers.html</description></item><item><title>Comment on Data Display using xamWebMap</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/22/data-display-using-xamwebmap?CommentId=a6f52b94-738e-4deb-9c79-8b750bc4ac7d</link><pubDate>Sun, 17 Jun 2012 23:17:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:a6f52b94-738e-4deb-9c79-8b750bc4ac7d</guid><dc:creator>huang</dc:creator><description>Thank you very much for you can share your post,the article content written very well, writes fluent,extremely is worth my study www.pandawill.com/.../batteries.html</description></item><item><title>Comment on Styling the xamWebGrid Group By Area</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/54/styling-the-xamwebgrid-group-by-area?CommentId=729524d6-3e31-4f2d-a9a0-9b2354032ac8</link><pubDate>Thu, 07 Jun 2012 05:54:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:729524d6-3e31-4f2d-a9a0-9b2354032ac8</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/.../batteries.html</description></item><item><title>Comment on Displaying AutoCAD drawings using xamWebMap</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/41/displaying-autocad-drawings-using-xamwebmap?CommentId=3d149672-a57d-4f70-ab81-95f63d6031b7</link><pubDate>Thu, 07 Jun 2012 05:54:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:3d149672-a57d-4f70-ab81-95f63d6031b7</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/.../keyboard-mice-c396.html</description></item><item><title>Comment on Using the VirtualCollection for Server-Side xamWebGrid Paging</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/55/using-the-virtualcollection-for-server-side-xamwebgrid-paging?CommentId=7c85019e-d7c9-4da7-bdbe-4aea9abad605</link><pubDate>Thu, 07 Jun 2012 05:52:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:7c85019e-d7c9-4da7-bdbe-4aea9abad605</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/.../keyboard-mice-c396.html</description></item><item><title>Comment on Conditional Formatting With The XamWebGrid</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/43/conditional-formatting-with-the-xamwebgrid?CommentId=d5fafa99-dbdf-437e-8753-38b0bec90854</link><pubDate>Thu, 07 Jun 2012 05:52:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:d5fafa99-dbdf-437e-8753-38b0bec90854</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/.../keyboard-mice-c396.html</description></item><item><title>Comment on Extension Methods for Navigating the xamDataChart</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/56/extension-methods-for-navigating-the-xamdatachart?CommentId=57a2dc95-a5cf-4fa9-ba28-5d56ad2a323c</link><pubDate>Thu, 07 Jun 2012 05:51:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:57a2dc95-a5cf-4fa9-ba28-5d56ad2a323c</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/huawei-ascend-p1-phone-android-40-os-ti-omap4460-dual-core-15ghz-1g-ram-3g-gps-wifi-43-inch-black-p62459.html</description></item><item><title>Comment on Custom Commands with Infragistics Silverlight Commanding Framework</title><link>https://www.infragistics.com/community/product_platforms/silverlight/w/silverlight-wiki/35/custom-commands-with-infragistics-silverlight-commanding-framework?CommentId=37b07565-3b9c-41e7-8713-c45683d9d562</link><pubDate>Thu, 07 Jun 2012 05:50:00 GMT</pubDate><guid isPermaLink="false">7a8b7c76-b7ad-48e0-9694-5b04ca132ed0:37b07565-3b9c-41e7-8713-c45683d9d562</guid><dc:creator>xiao</dc:creator><description>This article very good, I like, there is no article on electronic products can look to me, we exchange www.pandawill.com/gti9220-smart-phone-android-23-os-3g-gps-wifi-52-inch-50mp-camera-p62214.html</description></item></channel></rss>