We're working on a Silverlight application that uses a generic custom ContentControl. This ContentControl has a Control Template specified in a Generic.xaml.
The inherited ContentControl's Template...
<Style TargetType="local:ExtContentControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:ExtContentControl"> <Border x:Name="content" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Child="{TemplateBinding Content}"> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
The inherited ComboBox's Template...
<controltemplate targettype="local:ExtComboBox"></controltemplate>
...
<Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Margin="1" Opacity="0" RadiusY="2" RadiusX="2" Stroke="#FF6DBDD1" StrokeThickness="1"/>
When it is instantiated the ContentControl's content is set to a (generic) control which can be a Textbox, Dropdown, Label or Datepicker.
public class ExtContentControl : ContentControl { public ExtContentControl() { this.DefaultStyleKey = typeof(ExtContentControl); RenderControl(); } private void RenderControl() { ExtComboBox extComboBox = new ExtComboBox(); this.Content = extComboBox; } public override void OnApplyTemplate() { base.OnApplyTemplate(); Border bor = GetTemplateChild("content") as Border; ExtComboBox cmbTest = bor.Child as ExtComboBox; //Find FocusVisualElement from ExtComboBox Control Template //Rectangle rec = cmbTest.FindName("FocusVisualElement") as Rectangle; //cmbTest returns null } }
As you can see in my last comment...
//Find FocusVisualElement from ExtComboBox Control Template //Rectangle rec = cmbTest.FindName("FocusVisualElement") as Rectangle; //cmbTest returns null
How can I get hold of FocusVisualElement from inside OnApplyTemplate inside the ContentControl?
Hope this makes sense.
Answer: 1
Solution for this...
http://www.codeproject.com/Questions/192431/Hover-Foreground-Colour-with-dynamic-binding-Conte.aspx
by : madmaxhttp://stackoverflow.com/users/741694
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog