wpf

WPF doesn't always repaint when using WindowsFormsHost

I have a simple application which is hosting a Managed DirectX Control using WindowsFormsHost. I've overridden the paint methods in the Control to prevent flicker: protected override void OnPaint(PaintEventArgs e) { if (this.Visible == true) { base.OnPaint(e); } } // Don't paint the background unless the control is not visible prot...

Validation (with custom ErrorTemplate) for a DataTemplate

I can't figure this guy out / in desperate need of assistance. I have an ItemsControl and a DataTemplate as the ItemTemplate i.e. <DataTemplate> <StackPanel> <TextBox Text={Binding Prop1}/> <TextBox Text={Binding Prop2}/> </StackPanel> </DataTemplate> I have seen plenty of examples for applying validation to th...

Why the property is not called on Binding in WPF?

I am not sure why the property is not being called on Binding. Here is the code: <myusercontrol Text ="{Binding Description, UpdateSourceTrigger=LostFocus,Mode=TwoWay, ValidatesOnDataErrors=True}" IsReadOnly ="{Binding AllowEditing}" /> And here is the myusercontrol IsReadOnly property: public static DependencyProperty IsReadOnl...

WPF multitrigger referencing 2 other controls

I have two CheckBoxes and a TextBox. I want to TextBox to have IsEnabled=False if both CheckBoxes have IsChecked=False. Can I do this with a MultiTrigger? I keep getting errors trying to use the Source property. I have it working with MultiDataTriggers as you can see below. But have two questions. 1) Is this my only choice? Can I do it...

Wpf trigger to change the image of a treeview item

I am binding a treeview using a Hierarchical class structure as follows. Store ->ImagePath ->List ->List When I am creating the DataTemplate for the Person, I want to use a combination of the person.name and the image path declared in the Store. Here is the code behind of my MainWindow.xaml file. ` public partial class ...

WPF Theming and dynamic controls

Hello, I am trying to add control to ContentPresenter on then run, but control I've added does not apply theme. Theres is code with reference to theme in xaml file: <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources/PocGraphDataTemplates.xaml" /> </ResourceDictionary.MergedDictio...

Evaluate ContentControl without rendering to screen

I have a datagrid and I'm writing a method to search through it to find some text. Practically all of my columns use a DataTemplateSelector, so in my search, I need to be able to take a DataTemplate, apply it to a ContentControl, and then find a TextBlock to get the text to see if it matches my search criteria. I'm trying the following b...

Runtime-error in wpf with Window.AllowsTransparent set to true.

I get an exception thrown at runtime when I set AllowsTransparency="True" I get an exception saying the WindowStyle can not be set to None if AllowsTransparency is set to true. Even if I explicitly say that WindowStyle is set to SingleBorder I get this error. However, if I set WindowStyle to SingleBorder and remove the AllowsTransparency...

WPF: How to get the event when one FrameworkElement comes in contact with other FrameworkElement

I am developing a small application with images and trash box icon on right hand bottom. I have multiple images floating in the main window, and using mouse I can move image from one corner to other corner of window, left, right, top and bottom. I can't figure out how do I catch an event when a image touches and panel (with trash box ...

WPF FrameworkElement Parent and Moving a UIElement

I'm trying to move a control from one parent to another (if this will work I'm not quite sure). I can get a hold of the control that I want to move. Here is my code: public void MoveElement(UIElement uiElement) { var element = ((FrameworkElement)uiElement).Parent; //TODO:Remove from parent myControl.Children.Add(uiElement); ...

WPF Application Deployment Problem

i created a WPF application and i added a setup solution and i did everything to deploy the project and i got my setup.msi i installed it in my system, The problem is my application is running in task manager, but i cant see my application any where in desktop or start menu,but tast manager process show that my application is running. ...

WPF: Label to TextBox when selected

Hi!, I would like to create a simple designer which looks like visual studio. Specifically, I would like my items to have the same behavior as in VS: when they're not selected, a simple label/textblock is shown, when they're selected a textbox lets me edit the value. Which is the best way to achieve this? Thank you ...

What should be owner type of a routed command?

I am using wpf Custom Commands. While writing a custom Command, one need to define the owner type. It's Description says that it is the type that is registering the command. I was seeing some sample of custom commands and there the Owner type was UIElement and in some others it was the class name itself. Whats the difference? What should...

WPF and XPS: Empty Document Viewer

byte[] mediaBytes = Convert.FromBase64String("<<strings>>"); XpsDocument doc; ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length); Uri DocumentUri = new Uri("pack://document.xps"); using (Package package = Package.Open(ms, FileMode.Create)) { PackageStore.AddPackage(Docu...

Implementing custom CanExecuteChanged event with Commands in WPF

Hi everybody, I try to do a custom CanExecuteChanged event for a command button. Inside CanExecuteChanged event I would like to do some stuff when canExecute value change but I don't want to do it by implementing a custom command button class (deriving from Button and Implementing ICommandSource). Also I don't want to do my stuff into C...

WPF binding to current class property

Hello, I have a problem that i cant solve :( I have a user control (xaml file and cs file) in xaml it's like: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxm...

InvalidProgramException when calling Execute on DelegateCommand sub-class

Hi, I have a sub-class of DelegateCommand which fails with an InvalidProgramException, "The Command Language Runtime detected an invalid program." when I call Execute. My sub-class looks like this: public class SaveOrderCommand : DelegateCommand<IOrder> { [Dependency] public IOrderService OrderService { get; set; } p...

Customly chromed Windows in wpf

I've tried creating a customly chromed window in wpf using WindowStyle None, and AllowsTransparency True, however, when I maximize the window it covers the entire screen (and goes beond it's edges, it also hides the Windows-bar at the bottom of my screen, just like a game in fullscreen). How can I make the behaviour like a normal window,...

WPF ComboBox SelectedItem - change to previous value

Hello, I have a ComboBox that has the SelectedItem bound to the ViewModel. <ComboBox SelectedItem="{Binding SelItem, Mode=TwoWay}" ItemsSource="{Binding MyItems}"> When the user selects a new Item in the View ComboBox, I want to display a prompt and verify that they want to make the change. In the SetItem Property setter in the View ...

WPF Copy / Paste functionality

Hi all , I want to supply copy funtionality to my WPF app. I display texts in textblocks whitch comes from the server . The user cann't copy this texts and use them. How can do it ? Please you help. Thanks... ...