Telerik RadPageview从右到左布局箭头键

时间:2014-08-03 13:02:55

标签: telerik

我在Strip模式下有一个RadPageview,我希望我的程序支持从右到左的语言。当我将Right-to-Left属性更改为true时,它可以正常工作。但是当我运行我的程序并使用箭头键(左或右)时,它无法正常工作。左键转到右键和右键转到左侧。我该如何解决?

2 个答案:

答案 0 :(得分:0)

我通过使用表单的ProcessCmdKey以编程方式修复它。

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == (Keys.Right)) 
        {
            int x = radPageView1.Pages.IndexOf(this.radPageView1.SelectedPage) - 1;

            if (x < 0)
                x = radPageView1.Pages.Count() - 1;
            else if (x >= radPageView1.Pages.Count())
                x = 0;

            radPageView1.SelectedPage = radPageView1.Pages[x];
            return true;
        }
        else if(keyData == Keys.Left)
        {
            int x = radPageView1.Pages.IndexOf(this.radPageView1.SelectedPage) + 1;

            if (x <= 0)
                x = radPageView1.Pages.Count() - 1;
            else if (x >= radPageView1.Pages.Count())
                x = 0;

            radPageView1.SelectedPage = radPageView1.Pages[x];
            return true;
        }

        return base.ProcessCmdKey(ref msg, keyData);
    }

答案 1 :(得分:0)

Telerik回答了我的问题:

http://www.telerik.com/forums/right-to-left-arrow-keys-problem

我建议的可能解决方案是创建一个自定义RadPageViewStripElement并覆盖其IsNextKey和IsPreviousKey方法,以反转上一个/下一个导航,如下所示:

public class CustomPageView : RadPageView
{
    public override string ThemeClassName 
    {
        get
        {
            return typeof(RadPageView).FullName; 
        }
    }

    protected override RadPageViewElement CreateUI()
    {
        switch (this.ViewMode)
        {
            case PageViewMode.Strip:
                return new CustomRadPageViewStripElement();

            default:
                return base.CreateUI();
        }
    }
}

public class CustomRadPageViewStripElement : RadPageViewStripElement
{
    public CustomRadPageViewStripElement()
    {
    }

    protected override Type ThemeEffectiveType    
    {
        get   
        {
            return typeof(RadPageViewStripElement);    
        }
    }

    protected override bool IsNextKey(Keys key)
    {
        if (this.RightToLeft)
        {
            if (key == Keys.Left)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        return base.IsNextKey(key);
    }

    protected override bool IsPreviousKey(Keys key)
    {
        if (this.RightToLeft)
        {
            if (key == Keys.Right)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        return base.IsPreviousKey(key);
    }
}