wpf

Problem with custom scrolling in custom panel

Hello all. I'm coding a custom panel representing the hand of cards. It's a panel that will stack the cards horizontally. If there isn't enough space, each card will overlap part of the card left of it. Minimum part should be always visible. I accomplished this and this is the code: using System; using System.Windows; using System.Windo...

how to pass an integer as ConverterParameter?

hello, I am trying to bind to an integer property: <RadioButton Content="None" IsChecked="{Binding MyProperty, Converter={StaticResource IntToBoolConverter}, ConverterParameter=0}" /> and my converter is: [ValueConversion(typeof(int), typeof(bool))] public class IntToB...

WPF Design Considerations Using WebBrowser Control

I have to build a program that will allow me to track from a system different trigger points being hit. When a trigger has been hit within another system a web service is called, this web service will log to a database the following: Affiliate Id Trigger Id Reference Code My program is to read this data and invoke a call to affiliat...

Programatically Adding Controls

I have a class which adds items to a WPF Stackpanel however this does not seem to work instantantly it is working after i have restarted a timer on my page. Does this need some sort of event to refresh the WPF page and instantly make the changes take effect. Code: Ellipse myEllipse = new Ellipse(); SolidColorBrush mySolid...

Represent a City in WPF

Say, I build a dynamic map in WPF. I need to represent in this map locations(say, cities). The representation of a city is simple: a dot (circle or image) and the text. Both text and dot image are customizable. What would you recommend using as a CityControl in WPF? Examples: A UserControl having an <Ellipse>(or picture) and <...

Can you use a CollectionViewSource inside a DataTemplate?

Is it possible to explicitly use a CollectionViewSource inside a data template? Normally we'd put the CollectionViewSource in the resources alongside the template, but our model doesn't allow that because the 'source' of the collectionviewsource is a property of the DataContext at this level in the tree, meaning there needs to be an ins...

embeding and itegrate Flash movie in WPF application

Hi every body, I know that my question has been asked before but I didn't found any answer suitable for my case or even works. My problem is: I need to embed a Flash movie inside WPF application, then I need to use Externalinterface - or whatever the way is - to integrate through this flash movie - I'm working on Visual Studio 2008! I fo...

How to Dynamically Bind XML to a WPF DataGrid in C#

I looked around for this, but all the examples I could find used XAML, which made the solution too static. Here is what I want to do: I would like to populate a DataGrid's columns, rows and attributes from an XML file to be specified at run time. Nothing about the DataGrid's attributes can be fixed; the XML drives it down to the last ...

WPF losing data in previous page when a new page is created in Navigation window

Hi I have an app which uses the navigation window. THe page is designed this way. <Page> <Grid> <ComboBox/> <TextBox/> <Grid> <TextBox/> </Grid> <Grid> <TextBox/> </Grid> <ListBox/> </Grid> </Page> Now when i click a "new", i create a page, Page1 pg1 = new Page1(); this.NavigationService.Navigate(pg1); Now when i com...

WPF IValueConverter - converting multiple values into a single value

Hello everyone, I'm trying to maintain someone else's code right now where that person is a WPF expert. I, on the other hand, am not. :) The code uses the IValueConverter to convert a state enumeration into a boolean which governs whether or not a UserControl is displayed on the screen. I've discovered a shortcoming that a single en...

WPF bindings not refreshing

I have a listbox on my form that looks like this: <ListBox Name="lbResults" SelectionChanged="lbResults_SelectionChanged"/> I am binding the following collection to it: ObservableCollection<Hand> oHands = new ObservableCollection<Hand>(); using the following code: lbResults.DataContext = oHands; Binding binding = new Binding(); lb...

WPF Datagrid - Set Column visibility per row

Is there any way to hide a given column based on a binding. I've tried setting the visibility property on DataGridTextColumn (using the correct converter), but that doesn't seem to work. If I set the value directly (not through binding) it works. So is column visibility an all or nothing deal with the datagrid? ...

DataGrid row content vertical alignment

Hi, I have a regular DataGrid from WPF 4.0 RTM, where I put data from database. In order to make clean & light style of DataGrid I use a tall/high rows and by default DataGrid aligns row content in top vertical position, but I want to set a center vertical alignment. I already tried to use this property VerticalAlignment="Center" i...

c# settings + StackOverflowException

I have a usercontrol in my wpf application which is causing a stackoverflowexception to be caught when it is instanced more than once. I tried to debug the cause of the exception and it is raised during InitializeComponent of my Usercontrol. When I enter InitializeComponent it jumps over to the app.xaml.cs codebehind and reads values wh...

WPF - error handling with asynchronous command using BackgroundWorker

I'm using the AsyncDelegateCommand class from this blog post but I'm having trouble knowing what to do with exceptions that occur in my action delegate. I create the following command: new AsyncDelegateCommand( readFile, // action to perform () => shouldReadFile, // can the action be executed? obj => readFileFinished(true),...

WPF Grid saving position and also being collapsible

There have been many situation where I need to have a resizable area. It seems that using a grid and a gridsplitter to resize the columns is a good idea. However, with this I am unable to do one major thing. That is collapse one of the columns after resizing the grid. Also, saving the position of the grid splitter requires me to have atl...

How to get mouse position related to desktop in WPF?

Problem When you search for such question using google you get a lot of hits but all solutions assume you have at least one window. But my question is just like I phrased it -- not assumptions at all. I can have a window, but I could have zero windows (because I didn't even show one or I just closed the last one). So in short the solut...

Refresh UI with a Timer in WPF (with BackgroundWorker?)

Hi, guys. Here's my concern. We have an application in WPF that shows data via ObservableCollection. After 5 minutes, I want to refresh the data. I thought I could use the System.Timers.Timer object for its Elapsed event and then call a BackgroundWorker to call the method that starts the job. The method is on a ViewModel class. But i...

Changing DataTemplates at Runtime

I'd like to be able to swap out data templates at runtime, but without the FindResource("fdds") as DataTemplate Type of code I've seen a lot. I'd like to be able to just bind the template to look for the resource according to a property in my ViewModel. Conceptually I'd like to be able to do this, but the compiler obviously doesn't...

Can you add a handler for WPF event exceptions?

I have a single-threaded IronPython WPF application and if an event handler (FrameworkElement.SizeChanged for example) throws, the exception is just eaten and execution continues without any kind of notification. Because of this I spent a lot of time today solving an "impossible" bug. Does the same thing happen when using WPF from C#? ...