Issue with custom layout for RadVirtualKeyboard

1 Answer 30 Views
VirtualKeyboard
Dmi3
Top achievements
Rank 2
Dmi3 asked on 15 Feb 2024, 07:19 PM | edited on 15 Feb 2024, 07:20 PM

I would like use a RadVirtualKeyboard to enter pin code in my application. And when I use it with DefaultKeyboardLayout.Numpad it work as expected - shows small pop-up windows with numpad keyboard. But when I try to load my custom layout it shows the same small window but width of keyboard's buttons is super wide. 

I seems that loading custom layout reset width of UI element to full size keyboard and all my customs buttons are stretched.

Could you help me?

var kb = new RadVirtualKeyboard() { VirtualKeyboardTemplateSelector = (VirtualKeyboardTemplateSelector)(MyView.FindResource("KeyTemplateSelector")), DefaultKeyboardLayout = DefaultKeyboardLayout.Numpad }; keyboardWindow = new RadVirtualKeyboardWindow(kb) { Header = "Enter you number", ResizeMode = ResizeMode.NoResize, CanClose = false, Width = 260 };

//load custom layout

byte[] byteArray = Encoding.UTF8.GetBytes(keyLayout); Stream stream = new MemoryStream(byteArray); kb.LoadLayout(stream); keyboardWindow.Show();

Here is my layout:

<RadVirtualKeyboard xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="*" /> 
        </Grid.RowDefinitions> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="*" /> 
        </Grid.ColumnDefinitions> 
        <KeysLayout KeySpacing="0.1" Grid.Row="0" Grid.Column="0"> 
            <Rows> 
                <Row> 
                    <Keys> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="103" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="104" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="105" /> 
                        <Key KeyType="Normal" Width="1" Height="1" VirtualKey="109" /> 
                    </Keys> 
                </Row> 
                <Row> 
                    <Keys> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="100" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="101" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="102" /> 
                        <Key KeyType="Normal" Width="1" Height="1" VirtualKey="107" /> 
                    </Keys> 
                </Row> 
                <Row> 
                    <Keys> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="97" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="98" /> 
                        <Key KeyType="Numpad" Width="1" Height="1" VirtualKey="99" /> 
                        <Key DisplayText="Enter" KeyType="Special" Width="1" Height="1" VirtualKey="13" /> 
                    </Keys> 
                </Row> 
            </Rows> 
        </KeysLayout> 
    </Grid> 
</RadVirtualKeyboard> 

And how it is showed

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 19 Feb 2024, 10:20 AM

Hello Dmitry,

It seems that the virtual keyboard has a default size. You need to set in your code to something suitable for your case: 

var kb = new RadVirtualKeyboard();

var keyboardWindow = new RadVirtualKeyboardWindow(kb)
{
    Header = "Enter you number",
    ResizeMode = ResizeMode.CanResize,
    CanClose = false,
    Width = 270
};

//load custom layout

kb.Width = 250;
kb.LoadLayout(@"..\..\..\TextFile1.txt");

keyboardWindow.Show();

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
VirtualKeyboard
Asked by
Dmi3
Top achievements
Rank 2
Answers by
Dimitar
Telerik team
Share this question
or