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

How to make the Okbutton in the center,it is in right in default state!

5 Answers 71 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
PEIYANG
Top achievements
Rank 1
PEIYANG asked on 21 Aug 2012, 05:24 AM
How to make the Okbutton in the center,it is in right in default state!
The picture is here:https://www.yousendit.com/download/TEhYNnFFdVVENlRSc01UQw
This is my code,how to change it to make the button in the center? 
DialogParameters pars = new DialogParameters();
                pars.Header = "警告";
                pars.OkButtonContent = "  确定 ";
                pars.Content = "请选择";
                RadWindow.Alert(pars);

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 21 Aug 2012, 02:31 PM
Hello Peiyang,

You should modify the template of RadAlert in order to make the button appear in the center. The easiest way is to use Implicit Styles as explained here. You just need to find "RadAlertStyle" and make the modifications in it. Or you can create a new Style, copied from RadAlertStyle, and then set it to ContentStyle property of the DialogParameters:

<Style x:Key="NewRadAlertStyle" TargetType="telerik:RadAlert">
    <Setter Property="IsTabStop" Value="false" />
    <Setter Property="MinWidth" Value="275" />
    <Setter Property="MaxWidth" Value="500" />
    <Setter Property="SnapsToDevicePixels" Value="True" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="telerik:RadAlert">
                <Grid x:Name="LayoutRoot" FocusManager.FocusedElement="{Binding ElementName=OK}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.InputBindings>
                        <KeyBinding Key="Escape" Command="{x:Static telerik:WindowCommands.Confirm}" />
                    </Grid.InputBindings>
                    <ContentPresenter x:Name="Icon" VerticalAlignment="Top" Margin="20 20 6 8" ContentTemplate="{StaticResource AlertIconTemplate}" />
                    <ScrollViewer Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" IsTabStop="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0 0 0 8">
                        <ContentPresenter x:Name="AlertText" Margin="8 8 8 0" />
                    </ScrollViewer>
                    <Border x:Name="HorizontalRule" Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 0 0 1" Height="2"
                        Background="{StaticResource BorderLineOuterColor}" BorderBrush="{StaticResource BorderLineInnerColor}"
                        VerticalAlignment="Top" />
                    <telerik:RadButton x:Name="OK" Command="{x:Static telerik:WindowCommands.Confirm}"
                                    local:RadWindow.ResponseButton="Accept" Grid.Row="2" IsTabStop="True"
                                    TabIndex="0" Grid.ColumnSpan="2"
                                    MinWidth="70" HorizontalAlignment="Center"
                                    telerik:LocalizationManager.ResourceKey="Ok"  />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

and then:

DialogParameters pars = new DialogParameters();
pars.Header = "警告";
pars.OkButtonContent = "  确定 ";
pars.Content = "请选择";
pars.ContentStyle = Application.Current.Resources["NewRadAlertStyle"] as Style;
RadWindow.Alert(pars);     

The only difference from the default template is the HorizontalAlignment="Center" of the OK button.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
PEIYANG
Top achievements
Rank 1
answered on 22 Aug 2012, 12:21 AM
Can you give me a example?
 local:RadWindow.ResponseButton="Accept" Grid.Row="2" IsTabStop="True" ?  I run it says can't find "local" and other wrongs.
0
Yana
Telerik team
answered on 22 Aug 2012, 08:34 AM
Hi Peiyang,

Please find attached an example showing the exact approach.  Note that you should use NoXaml assemblies when using implicit styles.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
PEIYANG
Top achievements
Rank 1
answered on 22 Aug 2012, 07:48 PM
I have do according what you say, but it still wrong.
0
PEIYANG
Top achievements
Rank 1
answered on 25 Aug 2012, 12:51 PM
Here is my project ,I have do according to what you say,but it still fail.Can you tell what is wrong and how to solve it? Thank you!

This is my all project:https://www.yousendit.com/download/TEhWSlJ5VnNtUUUwTWNUQw
Tags
Window
Asked by
PEIYANG
Top achievements
Rank 1
Answers by
Yana
Telerik team
PEIYANG
Top achievements
Rank 1
Share this question
or