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

6 posts, 0 answers
  1. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 21 Aug 2012 Link to this post

    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);
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 21 Aug 2012 Link to this post

    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.

  3. DevCraft banner
  4. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 21 Aug 2012 Link to this post

    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.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 22 Aug 2012 Link to this post

    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.

  6. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 22 Aug 2012 Link to this post

    I have do according what you say, but it still wrong.
  7. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 25 Aug 2012 Link to this post

    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
Back to Top
DevCraft banner