Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:59:58+00:00 2026-06-10T01:59:58+00:00

I have created a WPF popup style and using it in many places in

  • 0

I have created a WPF popup style and using it in many places in the application.
The popup title is defined in the style and I’m not sure how to change it to different values throuhout the application, this is the style:

<Style x:Key="PopupContentStyle1" TargetType="ContentControl">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ContentControl">
                <Grid Height="90" Width="392" Background="Transparent">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.092*"></ColumnDefinition>
                            <ColumnDefinition Width="0.007*"/>
                            <ColumnDefinition Width="0.054*"/>
                            <ColumnDefinition Width="0.115*"/>
                            <ColumnDefinition Width="0.732*"/>
                        </Grid.ColumnDefinitions>
                        <Border CornerRadius="10" Grid.ColumnSpan="5">
                            <Border.Background>
                                <LinearGradientBrush
                            EndPoint="0.5,1"
                            StartPoint="0.5,0">
                                    <GradientStop Color="#FF333C3C"
                                Offset="0" />
                                    <GradientStop Color="#FF464646"
                                Offset="0.25" />
                                    <GradientStop Color="#FF504E50"
                                Offset="0.75" />
                                    <GradientStop Color="#FF595D59"
                                Offset="1" />
                                </LinearGradientBrush>
                            </Border.Background>

                            <Border Background="{DynamicResource TemplateBackgroundColour}" Margin="5,15,5,5" CornerRadius="5" BorderThickness="0,1,0,0">
                                <ContentPresenter />
                            </Border>
                        </Border>
                        <Label Name="popupTitle" Content="Sample title" Grid.Column="0" HorizontalAlignment="Center" Height="Auto" Margin="0" VerticalAlignment="Top" Width="Auto" Foreground="{DynamicResource DefaultFontColour}" Padding="0" Grid.ColumnSpan="5" />

                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

this is how i call and want to change the title to reflect popup content:

<Popup x:Name="p1" AllowsTransparency="True">
        <ContentControl Style="{StaticResource PopupContentStyle1}" >
            <ContentControl.Content>
                <Grid>
                    <TextBox>Popup user control goes here</TextBox>

                </Grid>
            </ContentControl.Content>

        </ContentControl>
    </Popup>

Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:00:00+00:00Added an answer on June 10, 2026 at 2:00 am

    The proper way to do this is making a custom contentcontrol and adding a “popupHeader” dependencyproperty to that class. That way, you can bind your header to that property straight away and you can still use your tag for other purposes.

    Make a class like PopUpHeader that inherits from contentcontrol and add a dependencyproperty to it.

    Create a class like this:

    public class PopUpHelper : ContentControl
    {
        public static readonly DependencyProperty PopUpHeaderProperty = DependencyProperty.Register("PopUpHeader", typeof(String), typeof(PopUpHelper), null);
        public string PopUpHeader
        {
            get { return Convert.ToString(GetValue(PopUpHeaderProperty)); }
            set { SetValue(PopUpHeaderProperty, value); }
        }
    }
    

    To be able to reference this in your XAML, input this namespace:

    xmlns:local=”clr-namespace:YourNamespace”

    where “YourNamespace” is the namespace you have put the above class in.

    Then change some targettype attributes in your style:

    <Style x:Key="PopupContentStyle1" TargetType="local:PopUpHelper">
    

    and also this line

    <ControlTemplate TargetType="local:PopUpHelper">
    

    change the binding of the content of your label to:

    Content="{TemplateBinding PopUpHeader}"
    

    You can use your new contentcontrol in your xaml like this:

    <local:PopUpHelper PopUpHeader="This is the header" Style="{StaticResource PopupContentStyle1}">
        <local:PopUpHelper.Content>
            <Grid>
                <TextBlock Text="Here goes content"/>
            </Grid>
        </local:PopUpHelper.Content>
    </local:PopUpHelper>
    

    If this would fail, check out the sample app I made for this: download

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a WPF chart programmatically and would like to change the Title's
I am creating a page-based WPF application using MVVM. I have created a custom
I have created a new WPF Application using Visual Studio 2010 so I have
I have created a wpf application into which I have added a user control
I have created a desktop application in WPF that I wish to supply to
I have created some tests in my WPF application. Right now I am working
We have created a beautifully designed .NET WPF desktop application. We are installing the
We have created a WCF RESTful service for a WPF(UI) Application. The UI sends
Greetings all, I have a question. I have created a WPF application. So, I
In my WPF application I have created a window and show it as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.