wpf

WPF - Events on a ControlTemplate?

Does anyone know why I can't set an event on a control template?? For example, the following line of code will not compile. It does this with any events in a control template. <ControlTemplate x:Key="DefaultTemplate" TargetType="ContentControl"> <StackPanel Loaded="StackPanel_Loaded"> </StackPanel> </ControlTemplate> I am usin...

How to validate child objects by implementing IDataErrorInfo on parent class

I am developing a WPF Application using MVVM Architecture. I am an amateur in WPF so bear with me.. I have two model classes. Parent class has an object of another (child) class as its property. (i mean nested objects and not inherited objects) For instance, consider the following scenario. public class Company { public string C...

Ultra-fast bitmap rendering using WPF, best solution ?

Hello there, I'm getting from our hardware device (FPGA) roughly 20 frames per second (500x500 px) and I would like to render them as fast as possible. We basically get a frame buffer every 50 msec and if my rendering is too slow - well... I'm skipping frames. My problem is to render from a C++/CLI driver to a WPF-based application. I ...

How to avoid recursive dependency properties

Hi friends: I have a class LineG inherited from a shape which will draw a simple line between two points.. I did that simply by adding two dependency properties StartPointProperty and EndPointProperty... Lastly I want to add another functionality which is MidPoint, so when I draw the line there will be a midPoint in the middle of the li...

How can I set different stroke properties to in a path object in WPF

I have a path shape that I would like to combine lines that have different line thicknesses? The StrokeThickness property is set on the Path object so I cannot change it for different lines. This same issue would arise if I wanted to change my line color. The reason I want to do this is so that I can draw an arrowhead. Charles Petzold a...

Same UserControl to add/edit/search

Hi, I have a UserControl in WPF that has a couple of fields to Add a New User. Can i use the same control to edit and update too ? ...

Why does Multibinding have NotifyOnTargetUpdated but no TargetUpdated property

I've run into a problem where the TargetUpdated event seemed like it would be perfect. Unfortunately it looks like Multibinding does not have a TargetUpdated property. Is there some way to still set this up or do I need to find another solution entirely. Heres some code to help Heres the binding... <RotateTransform x:Name="LeftNeedle"...

InlineUIElement not respecting clipping area of TextBlock

Hi. I have a TextBlock that contains some text in some Run elements, and which is set to CharacterEllipsis textclipping mode. However I also have a few InlineUIElements that contains some custom buttons. The problem is the buttons are showing up outside of the bounds of the TextBlock when they should be "clipped". Am I missing some exp...

Binding to a list control and finding views

I would like to bind a list control (like a ListView) in a view to a collection in a view model. The collection is made up of any number of view models which also have views designed to bind to them. While each view model in the collection will derive from a common base type, their derived types are different (as are the types of their...

Why does my data binding see the real value instead of the coerced value?

I'm writing a real NumericUpDown/Spinner control as an exercise to learn custom control authoring. I've got most of the behavior that I'm looking for, including appropriate coercion. One of my tests has revealed a flaw, however. My control has 3 dependency properties: Value, MaximumValue, and MinimumValue. I use coercion to ensure th...

Wpf UserControl Error

i create usercontrol when i add it on my wpf windows get this error: Error 47 The tag 'UserControl1' does not exist in XML namespace 'clr-namespace:WPFTestApp;assembly=WPFTestApp'. Line 115 Position 14. ...

iterating through open windows in wpf

i'm developing an application (wpf) that have 3 widow. in the main window user can open other window. when user wants to open window1 i'm create an instance of window1 and showing up that var win1 = new Window1(); win1.Owner = this; win1.Show(); now when user wants to close app, i want to iterate through each open window and check if ...

Changing Screen Resolution

I have a C# WPF application, I want it, when launched, to change the screen resolution if it is not what it should work on, like the games. I know how to retrieve the screen resolution, but I don`t know how to set it to what I want. NOTE: I`m not working with ASP or WEB, just a desktop APP ...

Creating and Printing Bitmaps from Visuals

I am trying to find an reusable and elegant way to create bitmaps from a visuals in WPF and then print the bitmap to a TLP-2844 zebra printer. The bitmap image needs to be 203 DPI since this is what the Zebra printer supports. I have tried everything I can think and I have to be missing something either completely obvious or what I am ...

WPF Button text wrap as far as possible and then scroll

As its container's width shrinks, I'm trying to get Button 1 to wrap its text until it can no longer do so, at which point the horizontal scrollbar kicks in. Right now, the button recognizes that it's got plenty of space due to the scrollviewer and doesn't wrap at all. <ScrollViewer HorizontalScrollBarVisibility="Auto"> <Grid> <...

Padding (left, right, top, bottom) in WPF

What I want to have is a button with a bit of left and right padding. I can set the MinWidth to some val, but if the Content will be changed it may not be enough. <Button MinWidth="75" Padding="2" Content="It speaks!" /> Is it possible to simulate something like Padding.left/right in WPF? ...

multiple grid layout wpf

I have a timesheet presentation which requires two grids, one for project (ie, billable) activities and one for all other activities. Each grid has a data entry column for every day of the week, as well as a Description column. The project section also requires the 1st column in the grid to display the Project Number. The totals for each...

How to invert the colors of a WPF custom control

Hello, I'm creating a custom control for my WPF application, and I'd like to know how I can invert the colors of the control when it's clicked. I've gotten it to respond to mouse clicks, but when I try swapping the background and foreground brushes, only the background color changes. The control is a die control and I want the colors ...

wpf popup doesn't close when focus is lost in xaml

Hi, I've written following xaml code to show a popup with the content in a expander control. all the things work ok up to the position where the popup opens when the button is clicked. but the popup wont close when I click away from it. plus as soon as I click away to close the popup my whole application seems to be freezed for a little...

Difference in creating Application object in WPF and WinForms

Why is there a difference in the way the Application object is created in WinForms and WPF? -> In WinForms we never created the Application object. It was always available (I believe it was Singleton pattern). In WPF, although hidden in App.g.cs we need to instantiate one. -> In WinForms it was a sealed class, but in WPF the way to go ...