wpf

WPF tab control spacing between headers

The default behavior of the WPF Tabcontrol is to place the Tab Headers adjacent to each other, without any empty space in between. What if I wanted to specify a gap between the headers? Do I have to define a control template for this? I'm relatively new to WFP and any help is appreciated. Thanks ...

Convert received keys in PreviewKeyDown to a string

I am using PreviewKeyDown event on a window to receive all the keys from a barcode scanner. The KeyEventArgs is an enumeration and does not given me the actual string. I dont want to use TextInput as some of the keys may get handled by the control itself and may not bubble up to the TextInput event. I am looking for a way to convert th...

Image Recognition to drive test automation

Are there any tools out there which uses Image Recognition(searching, comparing, validating images) as base for automating and testing GUI software.I know ranorex supports it. Are there any better tools?Are there any gotchas in using Image Recognition to drive test automation? ...

Please suggest a PDF viewer for WPF

I am looking into a PDF viewer control than can be used in WPF application. I saw some examples using WindowsFormHost but I am interested in rotating/resizing the pdf file. Please let me know if there is a solution. ...

How to add a trigger to a WPF custom control without overriding the existing style?

I am creating a simple custom control extending from toggle button that allows the user to specify checked and unchecked content directly in XAML. It works well but it is based on a trigger, and I don't know how to define the trigger except in a style. If I define the style, then I lose anything set outside of the custom control. What...

PreviewTextInput is not fired when the focus is on checkbox / Handling the PreviewTextInput in Main window and not allowing child control steal the characters

I have the following code. The window has a textbox and a checkbox. If I have focus on the anything other than checkbox and type something like 123-456 then for each character PreviewKeyDown and PreviewTextInput are firing. But if I have the focus to checkbox and then type 123-456 then the PreviewKeyDown is fired for all the characters...

How to drag a UserControl inside a Canvas

Hi, I'm writing my first WPF application. I have a Canvas in which user can add UserControl subclasses containing a form. User should be able to drag these UserControl around the Canvas. What's the best practice to do this with WPF? Thanks. ...

Unable to set System.Windows.Controls.MenuItem.Icon thru a setter

Hi I am trying to have a MenuItem.Icon set thru a style setter: <Style x:Key="MenuItem_Delete" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}"> <Setter Property="Header" Value="_Delete"/> <Setter Property="MenuItem.Icon"> <Setter.Value> <Image Source="Resources/Delete.png"/> ...

Will using the System.Windows.Controls in a window service cause issues

Background: We are currently looking at converting a piece of RTF text to a propriety format on a server. We currently have some spike code using the Richtextbox in the System.Windows.Controls namespace to convert the text to xaml and run it through a xslt transform to the required format. This works fine in the spike but have concerns...

WPF - How to make RadioButtons generated by a DataTemplate be mutually exclusive?

One of the apps I am building needs to build a survey for users to take. The relevant classes related to my question are: Survey (string Description, List<Questions> Questions, QuestionTypes Type) Question (string Description, List<Choice> Choices) Choice (string Description) enum QuestionTypes {MultipleChoicesOneAnswer, MultipleCho...

Set Window.DataContext to a declared property in the code-behind?

I want to achieve something like the following (Notice the DataContext property of the Window element): <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding MyDataContext}"/> Class Window1 Public ReadOnly...

MultiBinding binded to elements question

Hi! I have a login form that contains a username textbox and a password box. I want the ok button to be enabled only when both the fields contain a value. I have a converter that check for all the strings if they're null or empty. I placed a breakpoint on the first line of the Convert method, and it stops only when the MenuItem initial...

Can I have only a single row of a WPF DataGrid editable?

I have a data set that I want to display to the user, but I only want them to be able to edit the newest (first) row of data. I need to display the other rows of data to them for reference. I don’t have to keep everything in the same DataGrid but would like to if possible. I’m new to WPF so any help/ideas are greatly appreciated! ...

g.i.cs file not found with WPF and code contracts

Hello, I have a WPF project which compiles just fine. However, when I enable code contracts, I get a lot of errors like the following: file 'C:\MyProject\obj\Debug\MyFile.g.i.cs' could not be found Is there workaround? ...

WPF - prevent ListBox item selection

I would like to prevent selection of ListBoxItems in my ListBox. My DataTemplate has a checkbox and this should be the only thing the user can click or select. How can I do that? Thanks! ...

Work around for lack of Grouping in CompositeCollection

When I try to add a GroupDescriptor to my CompositeCollection I get an exception informing me that the CompositeCollection does not supporting grouping. I would like to know if anyone has found a good work around for this limitation. I have two collections which I am "zipping" together and trying to group. If it is any help, I am not in...

WPF Dragging causes renderer to stop

I'm having a problem with my WPF app, where any sort of drag operation stops the UI from updating. The issue seems periodic, as in, the item drags, stops, drags again, stops, etc. in 2 second intervals. It's affecting all controls, including scroll bars. If checked this question as well as this one, and it doesn't seem to be caused by w...

C#/WPF: Binding Combobox ItemSource in Datagrid to element outside of the DataContext

Hello, I'd like to do following: public List<Users> PreLoadedUserList { get; set; } public List<RowEntries> SomeDataRowList { get; set; } public class Users { public int Age { get; set; } public string Name { get; set; } } public class SomeDataRowList { public int UserAge { get; set; } Now my (WPF Toolkit) DataGrid look...

OverridesDefaultStyle in WPF

Can any one explain what OverridesDefaultStyle actually do to a control. I read MSDN, but I dont get the idea. ...

How to stop Tab navigation on wpf window on custom validations.

Hi everyone I have a requirement .I have a wpf form and having 4 text boxes for that i have st the TabIndex as (0,1,2,3) And i can do tab navigation. Now the requirement is i have a validation on the textbox4 (on the EditModeEnded or LostFocus event of textbox control i am doing a validation if value is not correct i display a messa...