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

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

DataGridCell Alignment Style Changing Width of Content?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery

It appears to when I use the following style to alter the cell alignment of a column, it is changing the width of the cell's contents to no longer expand to fill. This is problematic as it means I have to click in the narrow region shown in the second picture to edit the contents. What's the proper way to fix this?

Style code:


<Style x:Key="RightAlignStyle" TargetType="{x:Type DataGridCell}">
  <Setter Property="HorizontalAlignment" Value="Right" />


Width without Style:


Width with Style:

View Complete Post

More Related Resource Links

external content not load in page like style and js in asp.net mvc when i use area


i am working on a asp.net mvc 2 website who have a area and i have a problem with them.

i use different different url routing for application settings. i have two folder called style

first folder location in main directory  /Style/style.css

second folder location in Area area/style/style.css

everything is work fine in application but when i used style.css from main directory in my area's views then style not worked. when i track them from firebug then i got error "The resource could not be found" but path is correct.

sombody tell me to use absolute path to solve this issue. how i can use absolute path to declare resource url in views.

any suggestion , sollution on this issue who can help me to solve this issue.

Remove Word Style once copy and paste content to Rich text Editor in sharepoint 2010

Hi Guys, I have page layout for Users to add content for Page.I have site column for page content on field type HTML with Richtextmode="FUll Html". Now when user cut and paste content from Word document in this Field it carry word document style. how can i control this content on Page layout with CSS. Please adviseThanks Ron

WPF: Adding checkbox with content Textblock at dynamically - width width returns NaN

I want to add set of checkbox at runtime one by one in one column. So i am creating check box object with content Textblock (Textwrapping = wrap) and adding to wrappanel but width of controls is NaN so i am not able to set location(Y co ordinate) of next checkbox. int lastheight = 10; private void btnadd_Click(object sender, RoutedEventArgs e) { CheckBox chk_add = new CheckBox(); chk_add.MaxWidth = 100; TextBlock tb_add = new TextBlock(); tb_add.MaxWidth = 100; tb_add.TextWrapping = TextWrapping.Wrap; tb_add.Text = "Here is long text so that text block will get split over two lines....... blah blah blah"; chk_add.Content=tb_add;     chk_add.Margin = new Thickness(10, lastheight, 0, 0); wrapPanel1.Children.Add(chk_add); lastheight += (int)chk_add.Width; } Can any any one have idea how can i tackle this issue.

Changing the content type of a document

Hi everybody, Can we change the content type of a document ? For example, I have a custom content type 'A' that inherits from the default document content type. If I upload a document (on behalf of the windows explorer) and the default document content type is assigned, can I change it to the content type 'A' after ? Thanks in advance.Psyllos

ContentControl's ToolTip - issues changing Content

Hi all,   I'm having a few issues changing the Content of a ContentControl.   I have a collection of MyClass. One of these at a time has a property IsSpecial set to true. I loop through the collection, find which one it is, and set my ContentControl's Content to the "special" MyClass. Later, a different MyClass becomes special (and the older one's IsSpecial is set to false). I then loop through, and reset the Content to the new MyClass. The problem I have is nothing seems to be updating/changing - the DataTemplate is showing the data from the previous MyClass. Changing the Content from one object to another should work, right?   EDIT: Further testing shows that the Content IS changing, but the ContentControl's Tooltip is NOT. The tooltip is part of my DataTemplate.

changing the content of website runtime

say i have a table in my website that contain <tr>  and <td> and "hello good morning" is wriiten over there. how can change the content of my website to "hello good night" on a click of button or using any other way of doing  this like yahoo and other popular website did.

Can the style of tab container content be set globally for all tab content?


On our site we have set the font and font-size globally via CSS in the body tag.

however, since using tabs, it doesn't seem to understand our body tag CSS.

Do we have to set the style of each tab content individually?

Or can we do this globally and have one style setting which sets all our font-styles and sizes?

thanks in advance,

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?


WPF: how can ListBox display three columns: first and thrid column width base on the longest content


We try to use ListBox to display three columns: so the first and last column width will depend on the longest content in that column to decide and second column take the rest of space as its width.

How can we use ListBox to achive that?

should we try with the ListView? thx!

New window with width and height identitical to the page content


hi all forum

I have my NewsDetails.aspx page which displays a certain news  in a gridview according to the NewsId query string field. i wish to make the user able to print the page or mail it to a friend  so I used the following code

protected void ArticleGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        if (e.CommandName == "print")
            int NewsId = int.Parse(e.CommandArgument.ToString());
            string url = "ForPrint.aspx?NewsId=" + NewsId;
            string js = "<script language='JavaScript'>window.open('" + url + "','" + ArticleLbl.Text + "',";
            js += "'top=0,left=0,status=no,width=710,height=700,resizable=no,scrollbars= yes');";
            js += "</script>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), &

Changing crid cell content at runtime


In a cell in a grid, I have a TreeView. When the parsing of the data behind the treeview yields an error, I would like to replace the treeview with a textblock with information on the error details.

I'm thinking about using a datatemplateselector, but I can't figure out how, or if this is the best approach. Any suggestions?

Alternatively I will place a ContentControl in the grid cell and populate it with the correct content from the code behind file, I just think there could be a more elegant solution in pure XAML.

Dynamically changing the Style of TreeViewItem



I am currently setting the style to the Treeview control inside Treeview.Resources which works fine. I need to change the Style dynamically when user changes selection in another control. Any thoughts on how this can be done?

Here is my current working code.

<TreeView Name="NavigationPaneTreeView" SelectedItemChanged="NavigationPaneTreeViewSelectedItemChangedEventHandler"



Vertical alignment of DataGrid row content



I have a regular DataGrid from WPF 4.0 RTM, where I put data from database. In order to make clean & light style of DataGrid I use a tall/high rows and by default DataGrid aligns row content in top vertical position, but I want to set a center vertical alignment.

I already tried to use this property 


in DataGrid options, but it doesn't help me.

Here is an example of XAML-code, describing my DataGrid without center vertical alignment:

<DataGrid x:Name="ContentDataGrid"
		Style="{StaticResource ContentDataGrid}"

Changing the report width.


Hi All,

I have an sql server 2008 report with two tablixes: small one and a very wide one. The report has a Yes/No parameter which I use to show/hide appropriate tablix.

Is there way to shrink the report width when a user chooses to see small tablix? 


sharepoint changing content type layout has no effect on old pages




I have a content type layout. After I changed it, it had no effects on existing pages. 

When I add new page with this content type it has latest version.


How can I fix this? I want my current pages to use new content type layout.



Changing form width on loading or ... ??


I have a form for showing short messages to the user while program is running.

I want the form width to fit to the length of the message + some left/right margins.

I set the changing in the Form_Load with this code:

    private void formShortMessageForm_Load(object sender, EventArgs e)
      timer1.Interval = (int)tid;
      timer1.Enabled = true;
      const int margin = 50;
      this.Width = margin + label1.Text.Length * 6 + margin;

 but it don't work - the width does NOT change on the screen - where should I put the "changing-lines" so they do the job = changing the width on the screen ?

Best regards KSor, Denmark

Hide style library form view all site content



We have upgrade our MOSS 2007 server to SharePoint 2010. We keep it in MOSS2007 Competible mode, so that end user cant see any changes.

But after upgrading, we have found "style library" in document library, which was not present in our moss 2007 server. It is an publishing feature of MOSS2007.

Now we want to hide this "style library" from the document library, we have deactivated publishing feature on site collection and site level. But still, we are not able to hide or deactivate the "style library". Can anyone tell why it is so and provide solution to hide this?

Any help appreciated!!!

Thanks in advanced!!!

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