Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Style should not override all the properties of custom class in wpf.

$
0
0

I have a custom button Names ButtonSP with properties like TextKey, ColorKey.

In my view i created a button and use the properties of TextKey that will get the text from database to display content on button. ButtonSP has  a style to define the look of button with rounded rectangle.

My problem is If i use the style it overrrides all the properties of TextKey, colorkey with no content displayed on the button untill and unless if i specify the content="Some Text".

My style should not override the properties on BUtton.

Below is the code for ButtonSp

 <local:ButtonSP x:Name="DoneBtn"   Height="35" Width="164" TextAlignHorizontal="Center" TextColorKey="Black"TextKey="Prints.Done" FilePath="Style.xaml" TextCategoryEnum="FONTCAT_LABEL_LARGE" TextAlignVertical="Center" ColorKey="nButton.Background"  PathHeight="24" PathWidth="16"AutomationProperties.Name="DoneBtn" Margin="30,62,309,214"                        / >

Style.xaml

<ControlTemplate                 TargetType="Button"                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">    <Grid>        <Image>            <Image.Source>                <DrawingImage>                    <DrawingImage.Drawing>                        <GeometryDrawing >                            <GeometryDrawing.Pen>                                <Pen Brush="Black" Thickness="0.1"/>                            </GeometryDrawing.Pen>                            <GeometryDrawing.Geometry>                                <RectangleGeometry Rect="0,0,100,30" RadiusX="5" RadiusY="5"/>                            </GeometryDrawing.Geometry>                            <GeometryDrawing.Brush>                                <SolidColorBrush Color="#E8FFB422"/>                            </GeometryDrawing.Brush>                        </GeometryDrawing>                    </DrawingImage.Drawing>                </DrawingImage>            </Image.Source>        </Image>        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>    </Grid></ControlTemplate>

  Any help?        


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>