wpf

WPF: "Value of type 'String' cannot be converted to 'System.Windows.Media.ImageSource'."

I'm trying to set a WPF Image's source. XAML works: <Image Name="ImageThing" Source="images/Thing.png"/> Visual Basic fails: ImageThing.Source = "images/Thing.png" with this exception: Value of type 'String' cannot be converted to 'System.Windows.Media.ImageSource'. How do I create the System.Windows.Media.ImageSo...

Building a highly modular business application with WPF?

I'm fleshing out a WPF business application in my head and one thing that sparked my interest was how I should handle making it incredibly modular. For example, my main application would simply contain the basics to start the interface, load the modules, connect to the server, etc. These modules, in the form of class libraries, would con...

Trying to understand details of the Application Resource assignment...

I have a ComboBox with ItemsSource="{DynamicResource testResource}". The testResource is the Application resource that I set in C# code. What I have noticed is that if I load Window befor Application created, the resource is not loaded by ComboBox: Window window = (Window)LoadXaml("Window1.xaml"); Application app = new Application(); ...

Outside Property inside a DataTemplate WPF

Scenario: I have a ListBox and the ListBoxItems have a DataTemplate. What I want to do is put a ContextMenu in the DataTemplate. The catch is that I want this ContextMenu ItemsSource to be different depending on certain properties in the window. My initial thought is that I could just bind the ItemsSource to a Property in the window and ...

Shared resource dictionary between several user controls and across assemblies.

I have an assembly that contains several user controls. For this user controls assembly I want to have a resource dictionary. All the user controls within the assembly should be able to access the resource dictionary. Do I have to add <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> ... ...

How to detect a change in the Text property of a TextBlock?

Is there any way to detect a change in the Text property of a TextBlock element using events? (I'm trying to provide an animation for highlighting the TextBlocks whose Text property change within a DataGrid) ...

WPF: Style based on another one in a separate assembly

Assembly A - ResourceDictionary contains StyleA style. Assembly B - ResourceDictionary.MergedDictionaries to merge resources from Assembly A into B. I would like to create a style in Assembly B "based on" StyleA. Is it possible? I am trying to create this style: <Style x:Key="StyleB" BasedOn="{StaticResource StyleA}"> <Setter Pro...

WPF: Creating Application resource that requires parameter in constructor - how?

Hello, I am having a problem creating a resource in my App.xaml file. My problem is that I want to instantiate an object that requires a parameter in its constructor (my Linq-to-Sql DataContext, in this particular case), but I don't know if it's even possible to pass parameters like this in XAML. Does anyone know of a way to get arou...

Exception thrown when resources declaration order changed.

I get exception when declare resources in this order: <Window.Resources> <sys:Object x:Key="resourceA"></sys:Object> <x:Array x:Key="resourceB" Type="sys:String"> <sys:String>foo</sys:String> </x:Array> </Window.Resources> and when declare this way, all works: <Window.Resources> <x:Array x:Key="resourceB" Typ...

WPF Style Setter * Height and Width

I'm trying to create a WPF application which consists of a 9x9 grid with the row and columns using different styles. What I'm hoping to do is provide a star value for the height and width of the column and row definitions. This does not appear to work in the current context. Is this even possible, and if so, how? <Window x:Class="Baroqu...

WPF - How to apply style to AdornedElementPlaceholder's AdornedElement?

I'm trying to apply a style to an adorned element, but I don't know the correct syntax. Here is what I've tried: <!-- ValidationRule Based Validitaion Control Template --> <ControlTemplate x:Key="validationTemplate"...

WPF - Is there any way to programmatically evaluate a binding?

Does anyone know how to get the current value associated with a Binding? I ran into a problem recently where I wanted to get the value associated with a particular cell in the WPFToolKit DataGrid - so I created a function that gets the Path string, splits on '.' and tries uses PropertyDescriptor in a loop, trying to get the bound value....

Entity Framework - Bind Combobox to Normalised Table Field

I am currently trying to bind an entity to a form however I want to have DataConfidenceLevel (see below) bound to a combobox with ConfidenceDescription as the display member. What is the correct way to populate the combobox? (I am currently using WPF but a Winforms answer is acceptable) Thanks ...

WPF image manipulation

I have some idea of changing brightness in contrast, but i was wondering had a simple solution for changing brightness and contrast ...

Changing which DependencyProperty I bind to at run time

I'm using WPF and have a data class which I bind to a control's DependencyProperties. I need to change the binding at run time under the control of a user. Ideally I'd like to be able to do something like this myControl.SetBinding(UserControl.GetDependencyProperty("HeightProperty") , myBinding); Of course GetDependencyProperty tak...

Scaffolding for WPF using MVVM?

Hi there, Can anyone tell me if its possible (if some utility exists??) to create scaffolding taking into consideration MVVM with WPF. My idea here is i seem to have a lot fo data access forms, and of course i would like to Customize them but initially i would like a quick way of providing the form i.e. ALL controls placed on them and ...

programatically add column & rows to WPF Datagrid

Hello Guys, i m new to WPF. i just wana know how should we add Columns & rows programatically to DataGrid in WPF. The way we used to do it in windows forms. create table columns , rows & bind it to datagrid. i believe WPF datagrid is bit different the one used in ASP.net & Windows form ( correct me if i m wrong). Basically i have No ...

WPF decomposition - DataGridTemplateColumn

I am trying to move custom DataGrid column definition into a UserControl. MyComboBoxColumn.xaml <dg:DataGridTemplateColumn x:Class="WpfDecomposition.MyComboBoxColumn" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:Microsof...

WPF input gesture

Hi I am working a WPF application, where I have maintained a Menu Bar with Input Gestures i.e keyboard Shortcuts. For Save As menu item, I have kept Ctrl+A as per User's requirement. It works fine as far as the focus is on the main window. Now my problem is, suppose use has navigated in some Listbox in window, and if he presses Ctrl+A...

WPF MVVM Using Commands vs. Event Handlers

Hello, I like MVVM pattern, once you start using it, you get addicted to it. I know that in perfect world your View code-behind is almost empty (maybe some code in constructor) and every aspect of View is being manipulated from ViewModel. But there are times when creating new fields, properties,commands in ViewModel creates more code ...