Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've edited a template from a Button, then I added an Text into it without defining its "Content" property.

Style :
	xmlns:x="" xmlns:d="" xmlns:mc="" mc:Ignorable="d" xmlns:appStyles="clr-namespace:MyWin" x:Class="MyWin.WinEvent">
        <Style x:Key="WindowStyle1" TargetType="{x:Type Window}" >
                <Setter Property="Template">
                <ControlTemplate TargetType="{x:Type Window}">
                    <Border Name="Border1">
                        <Grid >
                            <Button DataContext="{x:Type appStyles:WinEvent}" Content="{Binding _Static}" Name="ButtonClick" HorizontalAlignment="Stretch" Height="51.443" Margin="1,0,0,0" VerticalAlignment="Top" Width="Auto">
         <EventSetter Event="Loaded" Handler="Load"/>

C# :
namespace MyWin
	partial class WinEvent

        private string _Static;
        public string State
            get { return _Static; }
                if (value != _Static)
                    _Static = value;

        private void Load(object sender, EventArgs e)
            State = "Click";


Thank you.
Updated 15-Jun-12 20:47pm
Sandeep Mewara 16-Jun-12 4:28am    
And the issue....?
SteveAdey 20-Jun-12 16:43pm    
I'd read some more books on WPF.
[no name] 22-Jun-12 15:47pm    
Was there a question here and I missed it?

1 solution

If I understand your question, I think what you need to do in create a new class that inherits from Button, and add a dependencyproperty(s) (or propety if do not need all the bells and whistles) for the value. Should be really easy.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900