How can I make a multi panel on-screen keyboard? (XAML) - wpf

We have an Intermec touchscreen terminal (OS: Win7).
We use an application on it that uses an on-screen keyboard stored in xaml files (VTFKey, VTKey, VTKeyCaps, VTKeyShifted, VTKeyShiftedCaps).
I pasted the code from VTKey.xaml for the buttons that toggle between keyboard panels (the xaml files mentioned above):
<Button Canvas.Top="105.545" Height="49.995" Width="125" Command="{Binding Path=PressAndRelease}" CommandParameter="VK_CAPITAL" Content="Cap" />
<Button Canvas.Left="724" Canvas.Top="208.692" Height="50" Width="90" Command="{Binding Path=PressAndRelease}" CommandParameter="VK_TOGGLE" Content="Toggle" />
<Button Style="{DynamicResource ShiftKey}" Canvas.Left="836.583" Canvas.Top="156.651" Height="50" Width="163.317" Command="{Binding Path=PressAndHold}" CommandParameter="RSHIFT" Content="Shift" />
My question would be how do these commands (VK_CAPITAL, VK_TOGGLE, RSHIFT) know which xaml file to change to?
How could I create a custom keyboard consisting of 6 customized panels(xaml files)? Is it even possible?
Thank you!

My question would be how do these commands (VK_CAPITAL, VK_TOGGLE, RSHIFT) know which xaml file to change to?
You have XAML for the following three Buttons:
<Button Canvas.Top="105.545" Height="49.995" Width="125"
Command="{Binding Path=PressAndRelease}" CommandParameter="VK_CAPITAL"
Content="Cap" />
<Button Canvas.Left="724" Canvas.Top="208.692" Height="50" Width="90"
Command="{Binding Path=PressAndRelease}" CommandParameter="VK_TOGGLE"
Content="Toggle" />
<Button Style="{DynamicResource ShiftKey}" Height="50" Width="163.317"
Command="{Binding Path=PressAndHold}" CommandParameter="RSHIFT"
Content="Shift" />
Note the Command property... this is the name of the ICommand instance that performs the functionality for each Button. Two of these Buttons use the PressAndRelease Command. In this case, the CommandParameter is also used... inside the PressAndRelease Command code, you would probably see something like this:
if (parameter == "VK_CAPITAL") LoadVkCapitalView();
...
else if (parameter == "VK_TOGGLE") LoadVkToggleView();
As for the last part of your question, you'll have ask a more precise question for me to be able to answer it.

Related

DevExpress PageSetupCommand - button greyed out. (What is its CanExecute() method doing?)

I have a WPF control with a button, whose command is bound to a DevExpress DocumentPreviewControl PageSetupCommand. However, this button always appears to be automatically greyed out.
<Button Content="Page Setup"
Command="{Binding PageSetupCommand, ElementName=binReportPrintSettings}"
MinWidth="90" MaxHeight="36" HorizontalAlignment="Left" Margin="8,0"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}"
IsEnabled="True"/>
.
.
.
<dxp:DocumentPreviewControl Grid.Column="2" CommandBarStyle="None"
x:Name="binReportPrintSettings" FocusVisualStyle="{x:Null}" ZoomMode="FitToWidth"
DocumentSource="{Binding Model.Report}"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}" />
After a bit of debugging, I've found that the binReportPrintSettings.PageSetupCommand.CanExecute() returns false which I'm thinking is the reason for this.
So for full disclosure - The Model.Report which the DocumentPreviewControl is bound to is null
(though I've also tried with a new XtraReport()). The reason for this is that what I actually plan to print is a PDF report which was supplied as binary data. The preview is actually displayed by a separate PdfViewerControl.
<dxpdf:PdfViewerControl Name="pdfReportViewer" DetachStreamOnLoadComplete="True"
DocumentSource="{Binding Model.BinaryReport.Data}"
CommandBarStyle="None" NumberOfRecentFiles="0" IsReadOnly="True"
ZoomMode="FitToVisible" ShowOpenFileOnStartScreen="False"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}">
</dxpdf:PdfViewerControl>
But the PdfViewerControl doesn't have a PageSetupCommand, and the DocumentPreviewControl can't accept an array of bytes / Memory stream as a DocumentSource (at least not for a PDF).
So my question is, is there a way I can display the PageSetupCommand (or the same Dialog box in some way) in this situation?

How to start using Ribbons in WPF

I tried referencing the System.Windows.Controls.Ribbon, the toolbox tab does not show up. If I right-click a tab and click show all, the tab is there, but controls aren't light up. I can add a tab and controls related manually, but after adding the ribbon, things like quickaccesstoolbar and menuitem does not work properly - they are being treated as tabs for some reason. Control groups don't work as well. Simply nothing works as it's supposed to.
I have tried editing XAML directly. It fails in the same manner as using the designer.
The tutorials online are either outdated, for a paid control suite, or simply don't work.
I don't want to use mark-up solutions like http://www.codeproject.com/Articles/364272/Easily-Add-a-Ribbon-into-a-WinForms-Application-Cs , I want something that works in a designer -- Is that too much to ask? If so I'll gladly go back to winforms.
If you work with ribbons, how did you do it? This question seems simple, but after digging for hours I still don't have an answer.
I'm an individual developer, making an open source, free software. As a student I really can't afford 1000$ control suites. I use VS2013 community, I tried using 2015 instead, but all the problems above are the same.
Add this reference:
and this namespace in the XAML file:
and try working with this code example:
<DockPanel>
<Ribbon DockPanel.Dock="Top" Margin="0,-22,0,0">
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu SmallImageSource="Images/list.png">
<RibbonApplicationMenu.AuxiliaryPaneContent>
<RibbonGallery ScrollViewer.VerticalScrollBarVisibility="Auto">
<RibbonGalleryCategory MaxColumnCount="1">
<RibbonGalleryItem
x:Name="GalleryItem1" Content="Application menu content"
MouseOverBackground="Transparent"
MouseOverBorderBrush="Transparent"
CheckedBackground="Transparent"
CheckedBorderBrush="Transparent"
/>
<RibbonGalleryItem>
<Hyperlink x:Name="hl1" Click="hl1_Click">
<Run Text="http://www.bing.com"/>
</Hyperlink>
</RibbonGalleryItem>
</RibbonGalleryCategory>
</RibbonGallery>
</RibbonApplicationMenu.AuxiliaryPaneContent>
<RibbonApplicationMenuItem x:Name="menuItem1" Header="Add"
ImageSource="Images/add.png"/>
<RibbonApplicationMenuItem x:Name="menuItem2" Header="Settings"
ImageSource="Images/system_preferences.png"/>
<RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab x:Name="rbnTab1" Header="Tab1">
<RibbonGroup x:Name="rbnGr1" Header="General">
<RibbonButton x:Name="btnRibbon1" Label="Save"
LargeImageSource="Images/filesave.png"/>
<RibbonButton x:Name="btnRibbon2" Label="Open"
LargeImageSource="Images/load.png"/>
</RibbonGroup>
<RibbonGroup x:Name="rbnGr2" Header="New group">
<RibbonButton x:Name="btnRibbon3" Label="Font"
LargeImageSource="Images/fonts.png"/>
<RibbonButton x:Name="btnRibbon4" Label="Delete"
LargeImageSource="Images/recycle_bin.png"/>
</RibbonGroup>
</RibbonTab>
<RibbonTab x:Name="rbnTab2" Header="Tab2">
<RibbonGroup x:Name="rbnGr3" Header="Other Group">
<RibbonButton x:Name="btnRibbon5" Label="Play"
LargeImageSource="Images/play.png"/>
<RibbonButton x:Name="btnRibbon6" Label="List"
LargeImageSource="Images/kmenuedit.png"/>
</RibbonGroup>
<RibbonGroup x:Name="rbnGr4" Header="What a group">
<RibbonButton x:Name="btnRibbon7" Label="Sleep"
LargeImageSource="Images/icon_sleep.png"/>
<RibbonButton x:Name="btnRibbon8" Label="Add"
LargeImageSource="Images/add.png"/>
</RibbonGroup>
</RibbonTab>
</Ribbon>
<Grid>
<!-- add your content here-->
</Grid>
</DockPanel>
You can remove the <Ribbon.ApplicationMenu> if you don't like it by addin this property Visibility="Collapsed"
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu Visibility="Collapsed">
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
Please take a look at the following. You should be able to have a very basic idea about Ribbon.
http://blogs.msdn.com/b/wpf/archive/2010/08/03/introducing-microsoft-ribbon-for-wpf.aspx
Sample project download
If you want to run the project, you need to change the project's .NET Framework version to 4.0 or above.
Add System.Window.Controls.Ribbon reference to the project
Remove reference like System.Window.Shell and RibbonControlLibrary
The sample should be able to run after you fixed all the namespaces in xmal and the codebehind .cs
http://blogs.msdn.com/b/wpf/archive/2010/08/03/building-a-simple-ribbon-application-in-wpf.aspx
Microsoft Ribbon for WPF (Get the one with Sample for more comprehensive sample)
http://www.microsoft.com/en-us/download/details.aspx?id=11877

Background Image of Button not showing in WPF

I have program in which I have lots of buttons. Each of button has background set as
<Button x:Name="mybutton" HorizontalAlignment="Left" Height="30" Margin="76,110,0,0" VerticalAlignment="Top" Width="25" Click="some_click">
<Button.Background>
<ImageBrush ImageSource="Resource/button_picture.png"/>
</Button.Background>
</Button>
Image is showing as background in .xaml when program not running but when i run application image is not there as background of button. How do i debug this background in button ? Is there any goofy error that is there?
Let's make sure we have the following properties set right in your scenario
1) Build Action -> Resource
2) Copy to Output Directory -> Do not copy
3) Instead of using the relative path for image source, try using a full path to the image like this (I say this because I don't know where the image resource is located in your project, using relative path is perfectly normal in WPF)
<Image Source="pack://application:,,,/AssemblyNameContainingImageResource;component/Resource/button_picture.png" />
You need to change the code like this
<Button x:Name="mybutton" HorizontalAlignment="Left" Height="30" Margin="76,110,0,0" VerticalAlignment="Top" Width="25" Click="some_click">
<Image Source="Resource/button_picture.png"/>
</Button>
Change the Build Action of button_picture.png to Resource if it is content. Also check the Copy to output directory property value

WPFToolkit:Split button dropdown button disable button

I am using WPF split button which is inherited from
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
The issue is I want to disable , the button ' the one below(Right side of Button 'Conf' in below 'downarrow present in the below fig) , If user clicks on Left side of the button the rightside should be disabled and the button(leftside) background should change to yellow.please find below the xaml , I am using the wpf split button , dropdown content in this case .please let me know if you have any idea
<extToolkit:SplitButton x:Name="ABCbutton"
VerticalAlignment="Center"
Command="{Binding ACommand}"
FontSize="16>
<TextBlock HorizontalAlignment="Center"
IsEnabled="{Binding IsEnabled, ElementName=AButton}"
Text="A"/>
<extToolkit:SplitButton.DropDownContent>
<StackPanel>
<Button Command="{Binding BCommand}"
Padding="3"
Style="{DynamicResource
DropDownButtonMenuButton}">
<TextBlock Margin="0,3,6,3"
Text="B"/>
</Button>
<Button Command="{Binding BCommand}"
Padding="3"
Style="{DynamicResource
DropDownButtonMenuButton}">
<TextBlock Margin="0,3,6,3"
HorizontalAlignment="Stretch"
Text="C"/>
</Button>
</StackPanel>
</extToolkit:SplitButton.DropDownContent>
</extToolkit:SplitButton>
In a case like this, you will likely be better off creating your own control. The split button can't really handle what you are talking about without a good deal of modification.
Essentially your new control will consist of two buttons, visually styled so that they look like they blend together. Each will have it's own background and enabled property. Add a ViewModel to help control behaviors and set properties, and I think you would be in business. Keep in mind that all of the controls that are supplied in any of the toolkits, frameworks, control packs, etc are made with the primitive types of drawing and framework elements (line, rectangle, border, content presenter, panel, etc) with specialized behavior code.
I end up making a lot of custom controls just because there is not one that perfectly replicates what I want.

Dialog form in wpf change content

I want to display a dialog form for new and edit actions... However title, buttons , and few other things should change.
I am wondering how i could implement this. Provide an enum value at constructor ? Like Mode.New or Mode.Edit ? Is there a way to avoid writing code like spNewButtons.Visibillity=Collapsed .. etc , and put it inside wpf ?
You can bind visibility with your mode property, and create a specific IValueConverter to convert the mode to a proper Visibility value. ie:
<StakPanel Visibility={Binding Mode,Converter={StaticResource myProperConverter}}></StackPanel>
Usually my WPF dialogs are all ContentControls that get displayed in a Popup.
My code usually looks like this:
<Grid Name="RootPanel">
<!-- Other Content -->
<!-- Popup is always last so it gets displayed on top of other contnet -->
<local:PopupPanel
local:PopupPanel.PopupParent="{Binding ElementName=RootPanel}"
local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}"
local:PopupPanel.PopupEnterKeyCommand="{Binding SaveCommand}"
local:PopupPanel.PopupEscapeKeyCommand="{Binding CancelCommand}">
<DockPanel>
<!-- Header -->
<Label DockPanel.Dock="Top" Content="{Binding PopupHeader}" />
<!-- Buttons -->
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Save" Command="{Binding PopupSaveCommand}" />
<Button Content="Cancel" Command="{Binding PopupCancelCommand}" />
</StackPanel>
<!-- Actual content displayed is determined by DataTemplates -->
<ContentControl Content="{Binding PopupContent}" />
</DockPanel>
</local:PopupPanel>
</Grid>
I removed a lot of the styles to make this easier to read, but you can see the general idea of how it's put together. My ViewModel usually contains properties for IsPopupVisible, PopupContent, and PopupHeader, and commands for PopupSaveCommand and PopupCancelCommand
I use my own custom popup in most cases, although the same thing could be done with a WPF popup.

Resources