This is a migrated thread and some comments may be shown as answers.

Control derived from RadMaskedNumericInput not visible when using a Style

1 Answer 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
DOUG
Top achievements
Rank 1
DOUG asked on 18 May 2011, 04:56 PM
I have created a custom control by deriving a class from the RadMaskedNumericInput control. It works fine until I create a resource style for it. Once the style exists, the control is no longer visible when running the app. When I tab, I can still give it focus, but it is not visible. It is visible when on a page in Visual Studio designer. I am working in WPF. The problem does not occur when wrapping the RadDatePicker.

Here is the derived class:

public class ccNumericTextBox : RadMaskedNumericInput

 

{

 

 

 

 

  public ccNumericTextBox()

 

  {

  }

 

 

 

 

 

 

 

  public override void EndInit()

  {

 

    base.EndInit();

 

  }

 

 

  protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)

  {

    this.SelectAll();

 

    base.OnGotKeyboardFocus(e);

 

  }

 

}

Here is the XAML:

<cc:ccNumericTextBox x:Name="txtDuration" Padding="2" Mask="#3.1" Height="22" Value="{Binding Path=Hours, Mode=TwoWay}"/>

 

 

 

Here is the Style:
<Style TargetType="{x:Type cc:ccNumericTextBox}">

   <Setter Property="Margin" Value="3,3,3,3"/>

 

</Style>

 

1 Answer, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 19 May 2011, 09:10 AM
Hi DOUG,

To resolve this, you can override the SetDefaultKey method and use the following code:

protected override void SetDefaultStyleKey()
{
    Theme theme = StyleManager.GetTheme(this);
    this.DefaultStyleKey = ThemeResourceKey.GetDefaultStyleKey(theme, typeof(RadMaskedNumericInput));
}
The reason why this is happening is because the template of the masked input controls comes from their base class. The wpf theming mechanism probably does not succeed to find the base style.

Kind regards,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
DOUG
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or