.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Canvas overlaps statusBar on Zoom !?

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :WPF

Hello everyone,


I have the following code:


            //Initialize the status bar.
            this.statusBar = new System.Windows.Controls.Primitives.StatusBar();

            //Set it at the bottom of the form.
            this.statusBar.SetValue(System.Windows.Controls.DockPanel.DockProperty, System.Windows.Controls.Dock.Bottom);

            //Add the button to the status bar.

            //Create a dock panel.
            DockPanel myDockPanel = new DockPanel();
            myDockPanel.LastChildFill = true;

            //Add cnavas fna the status bar to dock panel.

View Complete Post

More Related Resource Links

Change canvas size along with Zoom Out !?


Hello everyone,


I am working on something where I use mouse wheel to zoom in and out of the canvas.

I do;

this.canvas.RenderTransform = new ScaleTransform(currentMattrix.M11 + 0.1, currentMattrix.M22 + 0.1, e.GetPosition(this.canvasPanel).X, e.GetPosition(this.canvas).Y);

this.canvas.RenderTransform = new ScaleTransform(currentMattrix.M11 - 0.1, currentMattrix.M22 - 0.1, e.GetPosition(this.canvasPanel).X, e.GetPosition(this.canvas).Y);


My problem is, when I zoom out beyond currentMattrix.M11 < 1, I see the canvas shrink and the form around the canvas is visible.

How can I prevent this? Can I increase the Canvas size along with zoom out in the same proportion as of zoom or is there any other way?


P.S. I don't have a XAML file so doing everything through code and my canvas in inside a dock panel.



Wicked Code: Taking Silverlight Deep Zoom To The Next Level


With the help of Silverlight Deep Zoom and a remarkable control named MultiScaleImage, you can create scenes with many levels of zoom. Jeff Prosise illustrates with what else but the Mandlebrot set.

Jeff Prosise

MSDN Magazine July 2009

How to customize workflow canvas in re-host environment?

Hi there,  Currently I'm developing a re-hosted debugger for Windows Workflow.  For the workflow canvas, I'm using View property of WorkflowDesigner class and bind my ContentControl to it.  The question here is, how to customize the WorkflowDesigner.View? Examples of customization are:   Extract the overview window, so that I can put the window in another part of the UI Change the zoom tool into the slide bar as in MS Word.   Thanks and best regards,  Arinto

Saving Canvas and other UIElements as embedded resource

Hi All, I am trying to save a canvas and its content as an embedded resource to another assembly but in doing so I got a Non-Serializable exception. Is there a better way of doing this? Here is the code I used in embedding the Canvas: // create an assembly AssemblyName assemblyName = new AssemblyName(System.IO.Path.GetFileNameWithoutExtension(filename)); AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, assemblyName.Name + ".dll"); // create a class TypeBuilder typeBuilder = moduleBuilder.DefineType("ModuleName", TypeAttributes.Public, typeof(EmbeddedBAML)); // Create a default constructor ConstructorBuilder constuctorDefault = typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); ILGenerator ilGenerator = constuctorDefault.GetILGenerator(); ilGenerator.Emit(OpCodes.Ldarg_0); ilGenerator.Emit(OpCodes.Call, typeof(EmbeddedBAML).GetConstructor(Type.EmptyTypes)); ilGenerator.Emit(OpCodes.Ret); typeBuilder.CreateType(); IResourceWriter resourceWriter = assemblyBuilder.DefineResource(assemblyName.Name + ".canvas", "Contains the Canvas object",assemblyName.Name + ".canvas", ResourceAttributes.Pu

usercontrol layout in canvas at runtime puts in mult. copies of 1st element in collection.

I created a usercontrol which has a few DP's that match up with fields in a sql table. The requirements of this control specify if I get a specific status value I will flash the usercontrol to draw attention to a specific area of equipment in the facility. I also provide a tooltip which has all the fields of data to view. The usercontrol should only display it's description. On a button click I run the following code which instantiates a new observablecollection of my custom usercontrol (I call it profiNode). It then fills a dataset by calling our DAL and then I loop through the datarows using the values to create a new profiNode object for each row. I then add these to the observable collection, but I suppose a generic list would work too.     ProfiNodes = new ObservableCollection< profi.profiNode > (); DataSet data = new DataSet(); data = this.DataLayer.getDataSet("Select * from ProfibusMapping", CommandType.Text, null); foreach (DataRow row in data.Tables[0].Rows) { profi.profiNode node = new profi.profiNode((string)row.ItemArray[0],(int)row.ItemArray[1], (int)row.ItemArray[2], (int)row.ItemArray[3], (string)row.ItemArray[4], (DateTime)row.ItemArray[5], (int)row.ItemArray[6], (int)row.ItemArray[7], (string) row.ItemArray[8], (double)row.ItemArray[9], (double)row.ItemArray[10]); node.ID = string.Format("node_M{0}_A{1}&q

how to create property widget and change the properties of dragged-dropped UIelement in canvas in wp

I'm new in WPF development. I'd like to learn it. I'm curious and having problem in developing property widget for the UIElements. I want to change the properties of the dragged and dropped UIElement from the Property widget. How could I do this? I'd glad if any help is suggested. I've listbox and canvas. Elements from listbox can be dropped to the canvas. I'm trying to change the properties of the dropped element through a property widget. I don't know how to do this. I'd be grateful to any kind of support.   Regards, Binaya

different mouseWheel handlers for canvas and image

i have different mouse wheel handler for both canvas and image in that canvas,,but when i move my mouse over image and roll the wheel then the canvas mousewheel handler also starts working,,here is my code:   void img_MouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta > 1) { ((Image)sender).Width =((Image)sender).ActualWidth*1.01; ((Image)sender).Height = ((Image)sender).ActualHeight*1.01; } if (e.Delta < 1) { ((Image)sender).Width = ((Image)sender).ActualWidth/1.01; ((Image)sender).Height =((Image)sender).ActualHeight/1.01; } } <pre lang="x-c#">void mycanvas_MouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta > 1) { ((Canvas)sender).Width = ((Canvas)sender).ActualWidth*1.01; ((Canvas)sender).Height = ((Canvas)sender).ActualHeight*1.01; foreach(UIElement myElement in ((Canvas)sender).Children) { if (myElement is Image) { Image myimage = myElement as Image; myimage.Width *= 1.01 ; myimage.Height *= 1.01; } } } if (e.Delta < 1) { ((Canvas)sender).Width = ((Canvas)sender).ActualWidth /1.01; ((Canvas)sender).Height = ((Canvas)sender).ActualHeight/1.01; foreach (UIElement myElement in ((Canvas)sender).Children) { if (myElement is Image) { Image myimage = myElement as Imag

Seadragon mouse wheel motion zoom/zoomout not working

using following code.. vs 2008 andajaxtoolkit 3.5.40412.2what is is to be done to make it work? <form id="form1" runat="server"> <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </ajaxToolkit:ToolkitScriptManager> <ajaxToolkit:Seadragon ID="Seadragon2" Height="500px" Width="500px" runat="server" SourceUrl="dzc_output.xml" MouseNavEnabled="true" > </ajaxToolkit:Seadragon> </form>

Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc.,

Hello, I have a method that is passed in a FrameworkElement Ctrl.  When I use Ctrl.GetType().ToString() I get "System.Window.Controls.TextBox" or another string if a different type of control is passed in.  All I am interested in is the text after the last dot/period.  In my searching I thought I came across something that just returned the portion I'm looking for, but now can't find it. Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc., without its parents? Regards, Robert

SharePoint Excel Web Services - How do I adjust the Zoom Level

Hello, My Organization is using SharePoint 2010 and the Excel Web services module is installed.  The spreadsheet I am using loads perfectly on the page exept for one problem, the zoom level is at about 150% and I can't figure out how to zoom out.  Is there somebody out there that can please help me with this.  Thank you  

Slider control for zoom in/out

hi, i came across one problem while doing zoom in and out image on canvas using slider control. i have minimum and maximum limit for zoom lets say its 0.1 to 10 x (10 to 1000%) so i have set slider minimum and maximum value as 10 to 1000 respectively. It work fine with this. but now i want 100% in the center of slider. (just like in Excel 2007 or microsoft picture viewer). Can any one has idea how can i make 100% value in the center of slider. Regards, Suhas

Items data binding in Canvas

Hello! I have an ObservableCollection, which contains points with X and Y coordinates. I need to bind this ObservableCollection to Canvas control, but there is no way to bind collection directly to Canvas. I found a few samples with ItemsControl (and ListBox). <Canvas x:Name="Root"> <ItemsControl ItemsSource="{Binding AllObjects}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style> <Setter Property="Canvas.Left" Value="{Binding Longitude}" /> <Setter Property="Canvas.Top" Value="{Binding Latitude}" /> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type o:OperationPoint}"> <Ellipse Width="3" Height="3" Fill="Blue" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Canvas> It works, but there are many elements in visual tree I don't need: Canvas (Root) ItemsControl Border ItemsPresenter Canvas ContentPresenter Ellipse ContentPresenter

Ink Canvas or Ink Presenter



I need to load the jpeg image into asp.net page and allow the users to draw some sketches on the image and save the image with the sketches. I am able to do it using WPF Ink Canvas in Windows application but I really not sure how can I achieve the same in ASP.NET web application. Please can anyone throw some ideas on this.




How I can get coordinate textbox carete in Canvas.

Hi !
I have following xaml:

<UserControl x:Class="Dev1.Pronto.AD4.Modules.AdProcessing.Views.AdTextView"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Label Content="MyLabel"/>

Move all children on canvas or preferrably move the entire canvas



I´m working on a small app that parses the gpx file from the GPS. It will animate how me and my dog moves when we go hunting. I want to zoom in so that I can analyse how the dog is working and therefore need the graph to scroll and keep my position centered.

Yesterday I used a Canvas and plotted my points as black rectangles and the dog as red rectangles. Then used the SetLeft and SetTop to scroll the Canvas. I then added a polyline connecting the dogs points but didnt find StLeft and SetTop for the polyline. Played around with RenderTransform but never got it working.

1. My question is is canvas suitable for this?

2. Is there a way to move the entire canvas and all its children in one command?

3. Is there a generic way that can be used to move all UIElements.

By move I mean move relative an element relative to its current position, for example 2 pixels left and 5 pixels up.



Trying to learn

How to achive Zoom effect for Images



I may not be clear..But what exactly I want is when ever I focus on Image with mouse it should get enlarged and with mouse leave it should go back to its original resolution.

Any suggestion please...!

Please remember to click 'Mark as Answer' on the post that helped you. Unmark if it provides no help

Silverlight user control, canvas "layout root", no key events ever.



I'm trying to use a UserControl in Silverlight and I want to handle some key events. The user control is a network diagram, laying out data points in a circle and showing the relations between points. It consists of a canvas to which various shapes (ellipses for data points, lines for relations between points). I'd like it to be focusable and receive mouse and keyboard events to add support for things like rotation, scaling, and randomizing the layout of data points (how readable the diagram is depends on the data and where in the circle related data points are located, but I'm not going to attempt any smart layout logic that figures out where to put the points; instead, I simply allow the points to be laid out in random order along the circle); I was thinking F5 (with it's "reload/refresh" connotations) would be a neat key for this.

Trouble is, I am never ever receiving any key events. Mouse events apparently do bubble up to the canvas, but only from labels - the data points have labels - so I can handle them there. Currently this allows me to resize and rotate the diagram by scrolling the mouse wheel (with the shift key down to rotate, without to scale) if and only if the mouse cursor is over a label. Not *quite* what I want!

After some quick googling I've attempted to set IsTabStop to true on the UserControl containing the Canva

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend