.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

Setting the canvas height and width to Grid size

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :WPF

I have a canvas and I have it set to the following attributes


 Grid.Row="1" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="2"


However I want the canvas height and width to fill those locations. Also upon window resize i want the canvas height and width to adjust accordingly.

Any ideas? Thanks all

View Complete Post

More Related Resource Links

Setting size of Grid Since Ajax Resizer Changed It


I'm sure that wasn't a very good subject, but I couldn't think of a better one. What I have is a page that has an UpdatePanel on it with a GridView control in it. It was originally displaying at a particular height and width according to the CSS style I have setup for it in my style sheet. However, since adding an AJAX Resizer control to the UpdatePanel, it is now defaulting to a much smaller size.

How do I get the grid to default to that same height and width that is in its CSS class? I don't mind putting it in the ASPX page or whatever, just need the grid to default to a larger size than the small little box it defaults to since adding the AJAX resizer. 

WPF control size is larger than explicitly set width and height values.

I created a Canvas with fixed Width and Height (256x256). Next to it I put an Image control displaying a 256x256 texture without stretching. How is it possible that actual sizes of both controls on the screen differ so much? Here - is the screenshot illustrating size mismatch. And here - the TestLines256.png in case someone liked to check it (and maybe point out that I'm stupid and this texture is 180x180 and not 256x256 as I claimed). XAML with creation of the controls:   <Window x:Class="OversizedQuad.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" SizeToContent="WidthAndHeight"> <StackPanel Orientation="Horizontal"> <Canvas Width="256" Height="256" Background="Red" /> <Image Stretch="None" Source="TestLines256.png" /> </StackPanel>

Setting Width & Height on a WriteableBitmap

I am using a WriteableBitmap to convert System.Drawing.Bitmap - it seems to work nicely when I set the rect to 1024x768 like this: wbm.AddDirtyRect(new Int32Rect(0,0,1024,768); What if I want it to be dependent on screen resolution - if I do that, then it does not draw the Image fully - Any ideas on how to get it working for any resolution?

setting inline image size with css?

I have an inline image in the header of a page that's height is being set with CSS.  The actual height of the image is slightly taller than what it's currently set to with css.  I like doing this this way because it was easier to get the image to the right size.  It avoided multiple attempts in photoshop.Is it a bad idea to set the height of an image this way?   I'm only concerned with the major modern browsers.  Are there any side effects of this that I should be aware of?

How to change the size (width) of scorecard columns in Dashboard Designer?

Is there any way to change the size (width) of scorecard columns in Dashboard Designer?

How to Control each cells width and height of a Table ?

Hi, I want to fix the size of each cells of a table . for that i used Style like this: <td style="width:10px;height:10px"> contents </td> But it seems that there is no any effect of applying these settings.How can  i set its width and height. It seems that it purely depends on the contents of cells. Now, if suppose there are two rows, <tr id='r1'> <td id='d1'> content of size 10px </td> <td id='d2'> content of size 10px </td> </tr> <tr id='r2'> <td id='d3'> Content of size 400px </td> <td id='d4'> content of size 20px </td> </tr>   Then cell of id 'd1' will get a size of 400px ,since its just below cell is of size 400px. I want to fix its size. Is that possible ?  

Bar-graph style - how to keep columns in relative height of size of "graph"

Hi, I need some input for this and imagined that someone else had seen something like it: I have a box, let's say a grid, where there are some bars in it. These bars could be rectangles in a ItemsControl. The grid has a fixed height and width - but the rectangles' height (and width) are set a from a collection of numbers. These numbers go from 0 to 200 - but in periods the numbers only go from 1 to 10. If I use absolute numbers, the rectangles will be tiny in height or width if the numbers are between 1 and 10 and the Grid is 200 in height and width. How do I make the size of these rectangles relative to the tallest one? I guess I could do some calculations 'behind the scenes' in code, but is that really necessary? Is there no other way? Thanks! --Anders

SSRS BUG? When a FontStyle expression is used in a report, the Browser Text Size setting overrides t

I have created a report that has the same font size for all the sections in the report. Some sections' fields use a FontStyle expression that changes the FontStyle between Normal and Italics conditionally. I run the report through the reportserver interface and the report looks fine. I run the report through the ReportViewer control and the the fields which use the FontStyle formula are overridden by the Browser's Page Text Size. Also, when I look at the inline HTML Style that's generated, the fields with the formula don't have a style, they are blank, while the fields with without a FontStyle expression have an inline HTML Style generated. And this is probably why the browser text size setting can override. This seems like a ReportViewer HTML render bug... Or is there a way around it??

Button height doesn't increase with larger font size

Hi, I've got a couple buttons in a StackPanel that aren't increasing when I increase the font size. I think it has to do with the VerticalAlignment but I'm not catching what's going on. Here is the xaml: <StackPanel Grid.Row="3" Grid.RowSpan="1" Height="Auto" HorizontalAlignment="Stretch" Name="stackPanel1" VerticalAlignment="Stretch" Width="Auto" Orientation="Horizontal"> <Button Background="#FF7F3F96" BorderBrush="{x:Null}" Content="exit" FontFamily="Myriad Pro" FontSize="12" Foreground="White" Width="Auto" MinWidth="74" Margin="23,8,11,9" /> <Button BorderBrush="{x:Null}" Content="new" FontFamily="Myriad Pro" FontSize="12" Foreground="White" RenderTransformOrigin="-0.243,0.516" Width="Auto" MinWidth="74" Margin="11,8,11,9"> <Button.Background> <SolidColorBrush Color="{DynamicResource Green}" /> </Button.Background> </Button> </StackPanel>

how to fix the height of the table to be same as the screen size?

hi,iam trying to have my web page design inside a table that fills the screen in width and height.i tried like this<table  border="0" cellspacing="0" cellpadding="0"                         style="width:100%; height:100%; margin-right: 0px; margin-left:0;margin-top:0; margin-bottom: 0px;">            <tr> etc...the table width is filling 100 % but the height is not expanding to the bottom of the screen.my aim is to have a column in the table that looks like a left pane and it will contains dynamically added controls so if there is controls or no the column will have the height of the screenthanks for the help

TabContainer Auto Height and Width


Hi all,

How i can set auto Width and Height? it can be resize according to the data populate inside TabPanel.

Thank You

Setting .net windows control location based on Screen width

I am developing an windows application in 20 inch moniter. I am positioning the controls in WPF like this

scrollViewer1.Height = Screen.PrimaryScreen.Bounds.Height / 5;

If I run this application in 15 inch monitor whether it will change the position of the control or it will give the look and feel what i expected.

Please clarify?

If it will chnage the positioning,please suggest how to poistion the control to support all screens widths.

Detect Width and Height of .jpg image



I have an image on this path that I first check if it exists. If it exists I wonder what the method is to get width and height of this image ?

            if (File.Exists(Server.MapPath("Images\\Pic1.JPG")))
		    //How to get the Width and Height of this JPG Image ?


How can I have a page width re-size dynamicaly depending on its content


I am using the AJAX re-sizing control and the control I am wanting to resize is on the right side of the page, so when I resize it, most of the image isn't visible.  If I could get the page width to change as I resize the image it would be great.

How do I do that?


Cannot get Button size on Canvas


Hi All,

I am new to WPF and have stuck in a problem where I cannot get the size of a Button (a callout style applied to it). The button is added to the children collection of a Canvas.

What I am trying to do is to position the button relative to another uielement on the canvas. The button I want to have size of can have dynamic size and so I have to have the size to properly position it.

But no matter what property I use of button it's not giving the size. ActualWidth/Height, DesieredSize and RenderSize, Width and Height all give either 0,0 or NaN.



Setting the size of the tab indent for a rich text box


I have a form with a rich text box on it. I have the "AcceptsTab" property set to true. What I would like to do now is set the size of the indent that is made when you press the tab key.

Does anyone know how to do this?


Grid view width problem


how to fix grid view width using jqery

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