wpf

how to call a window's Loaded event in WPF MVVM?

It is easy enough to create a command from my OnLoaded() event handler code, but how do I call it from the View? <window Loaded="onLoaded"> doesn't cut the cake anymore since it calls code in the xaml.cs. How would I create an ICommand equivalent? ...

Listbox selection and DataTemplate

Hi I have a bounded listbox and I have created a DataTemplate that among other things have a button. I expected the listboxItem to get selected once I click the button but Its not working. Any ideas? ...

WPF Displaying Parent Child relationship

I can't wrap my head around how to accomplish rendering this public class Shape{} public class Circle: Shape{} public class Square: Shape { public List<Circle> CircleList{ get; private set; } } I have a List that holds Shape objects, now what I want to accomplish is having each object rendered in a grid. If the object is a Squar...

Why would adding an **appSettings** section to App.config cause an error in WPF application?

In my WPF application (Composite Application) I want to store a variable in the App.config file, but as soon as I add an appSettings section in App.config, it gives me this error: The type initializer for System.Windows.Application threw an exception. App.Config: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...

How can I set the color of a selected row in DataGrid

This seems like a no-brainer but i just can't see how to do it. The default background color of a selected row in DataGrid is so dark that I can't read it. Is there anyway of overriding it? Tried this (modified from Neverminds link) <dg:DataGrid.RowStyle> <Style TargetType="{x:Type dg:DataGridRow}"> ...

WPF HierarchicalDataTemplate

Could anyone explain how HierarchicalDataTemplate works What Controls supports HierarchicalDataTemplate? What does a control need to support HierarchicalDataTemplate? UPDATE What causes the TreeView to render the parent and child nodes when the same HierarchicalDataTemplate in a HeaderedItemsControl only causes the parent to be ren...

Change Background Color for WPF textbox in changed-state

I have a class EmployeeViewModel with 2 properties "FirstName" and "LastName". The class also has a dictionary with the changes of the properties. (The class implements INotifyPropertyChanged and IDataErrorInfo, everything is fine. In my view there is a textbox: <TextBox x:Name="firstNameTextBox" Text="{Binding Path=FirstName}" /> Ho...

Why isn't my exception being caught

I have an application that is mixed Winforms and WPF. In Winforms, I have a global exception handler that is defined as follows: AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; This ALWAYS catches exceptions anywhere in my application that occu...

Where to put the XML documentation comments for an attached property ?

Hi all, Assuming I have an attached property defined like that : public static string GetMyProperty(DependencyObject obj) { return (string)obj.GetValue(MyPropertyProperty); } public static void SetMyProperty(DependencyObject obj, string value) { obj.SetValue(MyPropertyProperty, value); } //...

How do you disable MouseOver effects on a Button in WPF?

I'm trying to disable the MouseOver effect on buttons, or at least change the colour of it, in WPF. I'm using the following style: <Style x:Key="Borderless" TargetType="{x:Type Button}"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Template"> <Setter.Value> ...

janrep WPF multipage reports

I've been investigating WPF mutipage reports and one option that looks interesting is WPF multipage reports - Part I. There seems to be a gap in the blog post or my understanding of how to get from the report.xaml to a ReportDefinition object. I think this should be really straight forward but I seem to be going around in circles. ...

if wpf app is not responding, then auto restart

I have a WPF application that occasionally crashes, and say "not responding". Is there a way to detect if the program is not responding? And if so, restart the WPF application? This will be a temporary fix until the bugs are fixed. ...

Dynamic Height and Width When Rendering XAML Buttons to PNG

I'm putting together a prototype to use XAML to create PNG buttons. The basic idea is that nice, gradient image buttons can be generated from localized strings instead of having them created by any sort of graphics dept. The most straightforward example I found actually was to build a C# assembly and call it from PHP. I converted it to...

Multiple Command Binding

Is it possible to bind the multiple commands to the button. I have a user control, which i am calling in my main application (parent application). I want to handle a click command on both the controls (the user control as well as on the main window). However i am only able to get one. Is there any way in which i can get this. Any hel...

WPF Toolkit Datagrid - how do you turn selection off?

I have a datagrid in WPF that I am binding to an object. I have a DataGridCheckBoxColumn on there which I want the users to be able to go through and tick the ones they want. Problem is they have to click twice, once for selection then again to check/uncheck. How on earth do you turn this off, I've been searching for way to long to fin...

PowerShell and WPF GUI freeze

I have a PowerShell function to look in a directory for zip files, extract it, and rename the files. The function also changes the status bar item to update what file it is on. I noticed that when this runs the GUI would freeze. How can I get the function run and update the GUI without it freezing? ...

WPF - Storyboard completed event

I'm designing a game like this class Anima { Storyboard story; Random rand; Canvas canvas; Ellipse target; public Anima() { rand = new Random(); canvas = new Canvas(); target = new Ellipse(); target.Fill = Brushes.Red; target.Width = 50; target.Height = 50; Canvas.SetLeft(target, rand.NextDouble() * 300); Canvas.S...

Change content of ImageButton programatically (WPF)

I am using a ImageButton as <Button Width="80" Height="25" VerticalAlignment="Top" HorizontalAlignment="Right" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0,0,1.5,0" Name...

WPF IEnumerable<T> vs IQueryable<T> as DataSource

Hi. I have a WPF ListView and I bind it to a IEnumerable<T> collection. Everything works fine, but when I bind it to the IQueryable<T> collection, there are no items in list anymore.. Why? Is it not observable or what? When I look at the definition: public interface IQueryable<T> : IEnumerable<T>, IQueryable, IEnumerable and public...

How does WPF solve cyclic dependent sizing?

I'm trying to figure out how come WPF doesn't go crazy when I set a window to resize to its content and then set its content to take all the available space... Any idea? ...