Hi,
I am using NetAdvantage for WPF and would like to add spin buttons, i.e. up and down buttons to a XamNumericEditor. How can I do that? Setting SpinWrap to true did not work.
For this, you would have to retemplate the editor (the EditTemplate) and put buttons (up/down) inside the ControlTemplate. You can see the default style in the DefaultStyles directory an use it as a base for your custom one.
Let me know if you have questions on this.
As you said, I added some control template like following:
<ControlTemplate x:Key="XamMaskedEditorControlTemplate1" TargetType="{x:Type igEditors:XamMaskedEditor}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="20"/> </Grid.ColumnDefinitions> <Border x:Name="MainBorder" BorderBrush="#FF00FF05" BorderThickness="2" Margin="1"> <TextBlock x:Name="TextBlock" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Text="{TemplateBinding DisplayText}"/> </Border> <Grid Margin="0" Grid.Column="1"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Button Content="+" d:LayoutOverrides="Height"/> <Button Content="-" d:LayoutOverrides="Height" Grid.Row="1"/> </Grid> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsEmbedded" Value="False"> <Setter Property="Padding" Value="4,2"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>
and then apply this control template to the XamNumericEditor. At this time I got some problem.
When I focusing to the NumericEditor, this template is disappear in UI.
What's wrong in this code?
Oops, I miss understood about the EditTemplate. :(
Thanks for your quick reply.
The editors have a second template property named EditTemplate that is used by default when the control goes into edit mode. If you want to use the same template while in edit mode you could bind the EditTemplate to the Template or set it to the same value. The sample template you have posted though wouldn't allow editing since you only have a TextBlock. You should look at the default xaml we ship with the product that is included in the DefaultStyles directory and use that as a basis for your custom template.