Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Can I set the template and style in xaml instead of code behind (Read 2658 times)
Dan Neely
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Oct 18th, 2016
Can I set the template and style in xaml instead of code behind
Dec 19th, 2016 at 7:06pm
Print Post  
Your example code all shows these being set in code behind; which means that the UI designer always shows your default layout instead of the layout I'm using.

ex from StyleSamples.cs in your example projects:

Code (C++)
Select All
virtualKeyboard.TemplateLayout = KeyboardLayout.Create(
                    this.GetType().Assembly.GetManifestResourceStream("Styles.CustomLayout.xml"));
//set custom style of VirtualKeyboardStyle from file
resources.Source = new Uri("/Styles;component/VirtualKeyboardWithImages.xaml", UriKind.Relative);
this.Resources.MergedDictionaries.Add(resources);
 



  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Can I set the template and style in xaml instead of code behind
Reply #1 - Dec 20th, 2016 at 4:08pm
Print Post  
You can define keyboard layout from Xaml like this -
Code
Select All
<vk:VirtualKeyboard>
	<vk:VirtualKeyboard.TemplateLayout>
		<vk:KeyboardLayout>
			<vk:KeyboardLayout.Keys>
				<vk:RegularKey Content="A" Left="10" Top="10" Width="60" Height="60" />
				<vk:RegularKey Content="B" Left="80" Top="10" Width="60" Height="60" />
				...
			</vk:KeyboardLayout.Keys>
		</vk:KeyboardLayout>
	</vk:VirtualKeyboard.TemplateLayout>
</vk:VirtualKeyboard> 



Seeing an external layout file created using the Keyboard Creator tool in VS design time should be possible too - try creating an IValueConverter that returns KeyboardLayout.Create(filename) from Convert method and use it in TemplateLayout binding expression.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint