Thursday, November 10, 2016

Content control in WPF application using C#

7:51 AM - By azeheruddin khan 0

Explanation: - Content control is a content model used for providing within a control like button. For ex: - providing some text and an image in a button as shown in the above given program. StackPanel is a control used for arranging a group of elements in the form of a stack; it also belongs to System.Windows.Controls namespace. <Button.Content> </ Button.Content> is the tag used for specifying content for a button. Image control is used to specify an image.

Program to show Content Control


<Window x:Class="ContentControl.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <Button Margin="135,110,199,28" Name="mybutton" Click="mybutton_Click">
                <StackPanel Width="166" Height="116">
                    <Image Source="c:\AJAY DESAI JPAL PHOTO.jpg" Width="139" Height="114"></Image>
        <TextBlock FontFamily="Baskerville Old Face" FontSize="18" FontStyle="Italic" Margin="178,258,240,32">INFOSYS</TextBlock>

MainWindow.xaml.cs (code behind MainWindow.xaml)

using System.Windows;

namespace ContentControl
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()

        private void mybutton_Click(object sender, RoutedEventArgs e)
            MessageBox.Show("Hi Ajay, Welcome to INFOSYS");

About the Author

I am Azeheruddin Khan having more than 6 year experience in c#, and ms sql.My work comprise of medium and enterprise level projects using and other Microsoft .net technologies. Please feel free to contact me for any queries via posting comments on my blog,i will try to reply as early as possible. Follow me @fresher2programmer
View all posts by admin →

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post



© 2014 Fresher2Programmer. WP Theme-junkie converted by Bloggertheme9
Powered by Blogger.
back to top