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 :
C#
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:appStyles="clr-namespace:MyWin" x:Class="MyWin.WinEvent">
        <Style x:Key="WindowStyle1" TargetType="{x:Type Window}" >
                <Setter Property="Template">
            <Setter.Value>
                <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">
                        </Grid>
                    </Border>
               </ControlTemplate>
            </Setter.Value>
         </Setter>
         <EventSetter Event="Loaded" Handler="Load"/>
     </style>
</ResourceDictionary>



C# :
C#
namespace MyWin
{
	partial class WinEvent
	{

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

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

    }
}


Thank you.
Posted
Updated 15-Jun-12 20:47pm
v2
Comments
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