Thursday, 15 May 2014

c# - WPF customControl and template inheritance -


I have a bit of trouble finding out how to proceed for my image butler template.

To simplify: I have created a new custom control image button by following this tutorial:

So far, very good, works very well.

But, on my application, I have a different possible topic for the button (application is initially known). And my separate button subject has been defined as:

  style x: key = "MONDE0_ImageActionButton" TargetType = "button" & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Border name = "baseborder" cornerreadia = "5" border color = "1" borderbrass = "black" background = "{dynamic rsource defaultblubton}" & gt; & Lt; Content display workspaceElement = "bottom" horizontal alignment = "true" margin = "0,0,2,0" & gt; & Lt; / ContentPresenter & gt; & Lt; / Border & gt; & Lt; ControlTemplate.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter target name = "baseborder" property = "background" value = "{static resetter default oversblue button}" /> & Lt; / Catalyst & gt; & Lt; Trigger Property = "Button Impressions" Value = "True" & gt; & Lt; Setter TargetName = "baseborder" property = "background" value = "{static resource defaultClickedBlueButton}" /> & Lt; / Catalyst & gt; & Lt; /ControlTemplate.Triggers> & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;  

The problem is, when I try to apply this topic to imgButton by me:

  & lt; VegaCtr: ImageButton x: name = "btn_Send" Margin = "5" style = "{Dynamic Resource MONDE0_actionButton}" width = "105" height = "40" tooltip = "Anwayr" command = "{binding message Command}" image = "Pack: // app: ;,,,,, Vega_WPF_Themes; component / themes / generic / images / yes.png" content = "vloder" />  

My image button style

  style target type = "{x: type local: image button}" x: name = "styleImgbutton" & gt; & Lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "{x: type local: ImageButton}" & gt; & Lt ;! - Button content - & gt; & Lt; StackPanel Orientation = "Horizontal" Horizontal Alignment = "Left" & gt; & Lt; Image Source = "{TemplateBinding image}" visibility = "{TemplateBinding image converter = {StaticResource VisibilityConvertor}}" Width = "{TemplateBinding ImageWidth}" height = "{TemplateBinding ImageHeight}" Margin = "0,0,5, 0 "/> & Lt; TextBlock Text = "{TemplateBinding Content}" style = "{static resource button label}" TextWrapping = "wrap" /> & Lt; / StackPanel & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;  

The base template for imageButton does not work. And when I remove the style feature, it works ... So, my question is, how can I work it out? I need a base image baton template and possibly add my second style (with trigger, etc ... etc). Is this possible?

Thank you!

Style based style on your style based on set

  & lt ; Style x: Key = "MONDE0_ImageActionButton" TargetType = "Button" BasedOn = "{StaticResource" My_BaseStyle "} & gt;  

No comments:

Post a Comment