.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

Orientation of child controls in UniformGrid

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :WPF
I have a list box that is bound to a list of images and uses a UniformGrid as an ItemPanel: <ListBox ItemsSource="{Binding Images}" SelectionMode="Extended" Name="ImageList"> <ListBox.ItemTemplate> <DataTemplate> <Image Source="{Binding}" Height="60" Width="80" Stretch="Uniform" Margin="2" VerticalAlignment="Center" HorizontalAlignment="Center"/> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> <ItemsPanelTemplate> <UniformGrid/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> This works great except for one thing. The child image controls are not centered horizontally within the layout grid columns. This is noticeable when you select an image from the ListBox and the blue highlight extends further on the right-hand side than on the left-hand side. How can I make sure the images are properly centered?

View Complete Post

More Related Resource Links

Accessing controls / events on a master page from child page

I have a problem i am trying to work out the best method with my limited skills. Im using vb.net ( VS 2010  ) I am using a dll for an IFrame , which is call from code behind.  On my site I havea masterpage which has two gridviews. ( GrdViewWebBureau is the one i am using for this  query)  GrdViewWebBureau is contained within an update panel and updated on a timer control trigger. GrdViewWebBureau updates the page with file counts and status from our clients. I can click on any one of the cells and the code behind is fired. What I am trying to do is put an IFrame on the master page and every time a user clicks on the grid, the Iframe is fired up.  I have tested the iframe and vb code behind from a dummy page and it works, however when the Iframe is on the master page it doeant work.  What I am tryingh to achieve is that no matter what page a user is on the site, they will be able to click on the GrdViewWebBureau and the iframe will fire with the correct childpage. Each webPage may also have an Iframe as well, so i dont know if it is possible to make the IFrame global and just call that control ??  I have no idea if 1 this is possible with the code i have and 2, if i have the brains to understand the who what why and when. Please can you look at my code and pass anyt suggestions / help /  solutions. Master Pa

How to force update all child controls values (like PropertyChanged but for entire child descendant



We need after event user fired (change at dataContext object) uptade all values binded to datacontext on controls descendant of grid control

¿Its is possible?


Julio Trujillo Leon. Microsoft Certified Professional Developer. .NET Developer and TFS admin. . Please, if my contribution is useful for you press on "useful button" Por favor, si les ha sido útil pulsen en "el mensaje ha sido útil" https://www.mcpvirtualbusinesscard.com/VBCServer/JulioTrujilloLeon/interactivecard

Find all child controls of a type



Given a normal WPF Window object, I want to walk the list of all controls contained in that Window and find all objects of a specific type...i.e. all of my UserControl objects that were placed in the XAML definition of that Window.  What's the best way to do that?


Not able to access child controls in user control using javascript



I have a user control "SettingsControl" containing an ajax:CollapsiblePanelExtender which in turn has a GridView (gridView) and checkBoxes. On top of GridView we have two LinkButtons "Select All" and "Clear All". I have written to enable select all and clear all functionality. Select All should select all the rows in the grid by calling the following JavaScript written on the Client .aspx file.

function SelectAll(chk)
    //get reference of GridView control
    var grid = document.getElementById('<%= SettingsControl1.FindControl("gridView").ClientID %>');
    //variable to contain the cell of the grid
    var cell;

    if (grid.rows.length > 0)
        //loop starts from 1. rows[0] points to the header.
        for (i=1; i<grid.rows.length; i++)
            //get the reference of first column
            cell = grid.rows[i].cells[0];


How to get child controls in a Webpart?


I have 2 controls in a webpart, a label and a button.

In button click event, I want change the button and label's text.

In the event, I can change the button1's text but cannot change the text by instance referent.


But I can use ((Lable)this.Controls[0]) to get the label control to change the text.


in debug mode, this.Controls[0] != lable1, this.Controls[1] == button1.


Is there any easier way to get childcontrol?


Thanks a lot!

Event bubbling - Mousehover event for child controls



I have a form and some controls inside it.

I want to fire an event when user enter the form and when he leaves the form .

this.MouseEnter += (sender, e) =>
   //do stuff

this.MouseLeave += (sender, e) =>
   //do stuff

the problem with that is when I move mouse over the child control, form's mouseleave event is triggered.

I don't want this to happen (even if the mouse over control is still over the form).


How to solve that?

I don't want to set any events on the children (because there are many controls and some of them create dynamically).

I also don't want to use any timers to check the position....

I know I can use IMessageFilter, and add to application:

 Application.AddMessageFilter(new MyMessageFilter());
 public bool PreFilterMessage(ref Message m)
if (m.Msg == 0x2a1) { }
But this will fire for entire application and not just for one form, and I don;t know how to detect inside PreFilterMessage the current control.



Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

GridView Parent Child View with JQuery Effects

I was just checked how to add some more cool effects to the GridView control using JQuery. In this post I will display parent-child data in the GridView control with some help of the wonderful JQuery library.

Let's first populate the GridView control.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

Using ASP.NET 3.5's ListView and DataPager Controls: Displaying Data with the ListView

Prior to ASP.NET 3.5, developers who needed to display a set of records could choose between the GridView, DataList, and Repeater controls. The GridView provides rich data features, but has a very boxy layout; the DataList and Repeater allow for a more flexible layout, but lack the "point and click" data features found in the GridView, DetailsView, and FormView controls. The ListView bridges the gap between layout flexibility and built-in data features.

This article, the first in a series of articles on the ListView and DataPager controls, looks at the ListView's many available templates and illustrates how to display data. Read on to learn more!

GridView control to show master-child or master-slave data, written in c#, asp.net

I previously made a master slave datagrid using Visual Studio 2003 .Net (original article) that would allow users to show data to clients using collapse and expand features. These features however did not carry over to gridview for many users. This tutorial will explaing how to create a collapsable/expandable gridview in frameworks 2.0 and higher

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

How to programmatically add controls to Windows forms at run time by using Visual C#

Create a Windows Forms Application
Start Visual Studio .NET or Visual Studio 2005 or a later version, and create a new Visual C# Windows Application project named WinControls. Form1 is added to the project by default.
Double-click Form1 to create and view the Form1_Load event procedure.
Add private instance variables to the Form1 class to work with common Windows controls. The Form1 class starts as follows:

Dynamically Create Controls in ASP.NET by Using Visual C# .NET

This article demonstrates how to dynamically create a control for an .aspx page. The sample project does the following:
Creates two TextBox controls.
Verifies that the contents (TextBox.text) and the attributes of the TextBox are saved across posts to the server.
Illustrates handling events that are posted by a dynamically-created control

Dynamically Create Controls in ASP.NET with Visual Basic .NET

This step-by-step article describes how to dynamically create controls for an ASPX Web page.

The sample project does the following:
It creates two TextBox controls.
It verifies that the TextBox contents (TextBox.text) and attributes are saved across posts to the server.
It describes how events that are posted by a dynamically created control are handled.
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