wpf

How to execute WPF assembly from memory?

If the ms variable is a MemoryStream and contains a .Net assembly, you would normally run it like this: var asm = Assembly.Load(ms.ToArray()); var entry = asm.EntryPoint; var inst = asm.CreateInstance(entry.Name); entry.Invoke(inst, null); This works well on console applications and windows forms applications, however, WPF applicat...

Blend Slider Control

Is there a free implementation of the text box in Blend's property grid that allows you to change the number by clicking and dragging? Or perhaps another way to ask is what kind of control called so I can google it? ...

C# WPF - ComboBox to also be a TextBox, for example: just like in office where users can choose Font Size or enter it

Hi, I would like to allow users to choose a Font Size from a ComboBox, but i would also like them to be able to enter the size by there own, i tried out the property: "IsEditable" (and changed it to true as value) of the ComboBox, but when i enter something that isn't in the ComboBox items (for example: my items are- 2,3,4;and i entered-...

Why does Dispatcher.Invoke not execute the delegate argument in this example ?

[Test] public void A() { var d = Dispatcher.CurrentDispatcher; Action action = () => Console.WriteLine("Dispatcher invoked me!"); var worker = new BackgroundWorker(); worker.DoWork += SomeWork; //worker.RunWorkerAsync( (Action) delegate { Console.WriteLine("This works!"); } ); ...

How to properly wait for multiple threads that call Dispatcher.Invoke to finish in WPF application

I have a WPF application that kicks off 3 threads and needs to wait for them to finish. I have read many posts here that deal with this but none seem to address the situation where the thread code calls Dispatcher.Invoke or Dispatcher.BeginInvoke. If I use the thread's Join() method or a ManualResetEvent, the thread blocks on the Invoke ...

CollectionViewSource Filtering Event vs Property

What are some of the practical differences between using the CollectionViewSource.View.Filter property as opposed to the CollectionViewSource.Filter event? Are there situations where you would use one over the other or is it a matter of preference? Cheers, Berryl EDIT: I do see that the docs say "If your view object comes from a Colle...

How do I refer to root project directory in WPF XAML when setting paths to other files?

I'm having issues referring to image files and other XAML files when the files are in a higher level directory then the XAML file from which I am referring to them from. Is there a way to refer to the root of the project directory? For example I have the following files & directories: Project Root Folder: \root Icon in root folder: \r...

WPF: Copy from a DataGrid

I would like to add Copy functionality to a WPF DataGrid. The Copy option should appear in a right-click menu It should copy the display text for the selected cell. (I am using read-only text columns.) ...

Wpf AttachedBehavior losing base textbox functionalty when using it.

I have a attached behavior issue. When I attach the behavior to my textbox I lose all my base functionality like the Max length? Here is how I am attaching it in my xaml. When I take off the attached behavior the max length work when I put it back on it doesnt work? Any help would be greatly appreciated! This is the class I am usin...

On creating expensive WPF objects and multithreading

The classic advice in multithreading programing is to do processor heavy work on a background thread and return the result to the UI thread for minor processing (update a label, etc). What if generating the WPF element itself is the operation which is expensive? I'm working with a third party library which generates some intense elemen...

WPF DataGrid Grouping does not show up due to binding error

Hello, I get this error message: System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='System.Windows.Data.ListCollectionView' BindingExpression:Path=MaterialList; DataItem='MaterialBrowserListViewModel' (HashCode=24964411); target element is 'CollectionViewSource' (HashCode=365180...

How do I leverage a control from a C++/CLI project for use in my WPF application?

First of all, my knowledge of C++ is effectively zero. I'm a .NET developer but even my interop experience is minimal. I have found an example of a control written in C++/CLI that grabs and displays a webcam feed using DirectShow. I'd like to take this example and utilize it from my WPF application. I've tried (and butchered) several d...

Call a method when specific key combination is pressed anywhere in the app, as long as application is currently focused window

My objective is to allow users of my app to bringup what I'm calling my debug console by pressing CTRL + F11 on their keyboard. Simply put, I need to call a ToggleDebug(); method, which will enable my debug tracing code and display the window. I'd like for my application to do this at any point when CTRL + F11 is pressed, regardless of...

BITMAPINFOHEADER to BitmapSource

Hi, I have c# app, that has a callback method, and the only parameter this method has is an IntPtr that is a pointer to a BITMAPINFOHEADER Structure. I need to convert it to a BitmapSource object to use with WPF. Using Marshal.Read* I can know its width and height etc... but I don't know how to generate a BitmapSource... Anyone knows h...

How to grab keyboard from child controls in WPF?

I have some inputbindings in a Window: <Window.InputBindings> <KeyBinding Key="Space" Command="{Binding Path=StepNext}" /> <KeyBinding Key="R" Command="{Binding Path=ResetSong}" /> <KeyBinding Key="Left" Command="{Binding Path=StepPrevious}" /> </Window.InputBindings> The commands are defined in my viewmodel a...

WPF: StringFormat problems with a Label

These versions work as expected: <DataGridTextColumn Header="Total Units" Binding="{Binding TotalUnits, Mode=OneWay, StringFormat=N0}"/> <TextBlock Text="{Binding TotalUnits, Mode=OneWay, StringFormat=N0}"/> When I try it with a label, the StringFormat is iqnored and I get "123.000000" instead of "123". <Label Content="{Binding Tot...

Implementation of toolbar with icons in WPF/XAML

In my desktop-based WPF-application I want to implement a toolbar with key actions (add, update, delete etc.), something like you can see in any web-interface mail-service. In order to make it I have a large PNG-image with all possible icons (regular, active, disabled, etc.) So, my question is how to show not the whole image, but only ...

WPF datatemplate ItemsControl specifying initial and final values

I have been using ItemsControl for quiet sometime in WPF. I am using MVVM for developing my application. Now I have run into a problem. I have a requirement where in based on number of values in a IList<> , I have to display the number of TextBoxes separated by a comma in between. I have written an ItemsControl which iterates over the b...

how to create checker board pattern ?

hello, probably a trivial question: i need to fill a rectangle with a checker board pattern where each cell is 1x1 pixel in size. how to create a vector geometry for this pattern in XAML? i am not using Blend I am doing my vector graphics by hand. thanks konstantin ...

How to make my WPF MainWindow a singleton?

I want to make my MainWindow a singleton because I want to make accessing it from all other windows in my app easier. But I couldn't make it run. Here is what I did. As usual, I made the MainWindow contractor private, and created a public static MainWindow Instance property to return a static instance. When I just run it without any oth...