wpf

Binding an Image in WPF ?

Hi, I wanna show an image in WPF that is created by a process, e.g : we have a method that is named createWPFImage() Image createWPFImage() { ... } So, the output of createWPFImage() is an Image. In the XAML code, we have a something like below : <StackPanel.ToolTip> <StackPanel Orientation="Horizontal"> <Image Width="64"...

Using ImportingConstructorAttribute

Hi, I'm trying to build a WPF application using MEF and MVVM. I'm exporting my ViewModel but I want my ViewModels to accept a Model parameter in the constructor: I will create a specific Model and supply it to ViewModel's constructor. I've tried to understand how ImportingConstructorAttribute works, it seems like it is the way to have a...

How to bind xml to the WPF DataGrid correctly?

I have looked for and tried various solutions but so far none of them solve my problem. I am using the built-in DataGrid from WPF in Visual Studio 2010/.NET4 to display data from an XML document stored as an XDocument. My code all runs fine, and I have verified that the XDocument is present and correct. The DataGrid does not display any...

How to style the selected item of a ListBox to look like a selected item of a ListView (with GridView)?

I'd like to have the selected item of a ListBox on the right to look like the selected item of a ListView (with GridView) on the left. This is the XAML code: <Grid> <StackPanel Orientation="Horizontal" > <ListView Margin="4" Width="200" > <ListView.View> <GridView> <Grid...

In WPF, view a portion of an image

We have an image where we create view box coordinates that are topleft/bottom right points within the image that are setup to allow for viewing portions of an image at different times in our application. In WPF, how do we load an image, and with topleft/bottom right points within that image, only show the portion of the image within tha...

C#, WPF, Updating the gui without backgroundworkers

I have a program that takes 10-20 seconds to start. I need to show a window with a progress bar when the program starts up. I know BackgroundWorker's are the correct way to do this but I unfortunately don't have the time to rework the whole gui using threads right now. Here is some code I'm trying but it is not working. Can anyone help.....

WPF multithreading

I'm scratching my head in trying to get the multithreading to work as I want in WPF I have an object (with a singleton) called Manager which does alot of processing and lookups. I want it to run in a separate thread from the UI, The UI will call methods on Manager to do the processing and fire events that the UI should react to I'm con...

C#, WPF - OpenFileDialog does not appear

I have been searching up and down the web and unfortunately never came across an issue quite like mine, so here goes: My C# WPF application won't show me no OpenFileDialogs or SafeFileDialogs. private void btnBrowseNet_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.CheckPath...

WPF Toolbar Items HorizontalAligment="Right"

Is it possible to make the elements within a WPF toolbar have a HorizontalAlignment of Right? <ToolBar Height="38" VerticalAlignment="Top" Grid.Row="1"> <Button HorizontalAlignment="Left" Width="50" VerticalAlignment="Stretch"/> <Button HorizontalAlignment="Left" Width="50" VerticalAlignment="Stretch"/> <ComboBox Width="120"...

WPF Databound RadioButton ListBox

I am having problems getting a databound radiobutton listbox in WPF to respond to user input and reflect changes to the data it's bound to (i.e., to making changes in the code). The user input side works fine (i.e., I can select a radiobutton and the list behaves as expected). But every attempt to change the selection in code fails. Sile...

What is a good model for IoC + Ribbon?

We are using an IoC model for our WPF tools, and are quite happy with how it's all working out. Now we want to add a ribbon to a new tool we're creating, and I'm running into some design problems. I'm looking for guidance on how plugins in our tool can expose their interfaces to the main window's ribbon. We want to be able to continue ...

RichTextBox CaretPosition physical location

Hi, I'm using a RichTextBox class to make some automatic text formatting. And mz question is, how do I get the RichTextBox to put some string immediately after the caret. When I use RichTextBox.CaretPosition.InsertTextInRun("some string") the text is inserted after the current logical block, but I need to be insterted immediately after ...

WPF: Referencing app-wide resources in code-behind

I have made my own custom converter which given a string returns a Brush. Now I'm able to return constant brushes such as Brushes.Red etc., but I really want to use my own colors which I have defined in an application-wide resource. How do I reference application-wide resources from my own custom converter class? I'd use FindResource bu...

Creating a VisualBrush without ever displaying the Visual it represents.

Using the code below, I am attempting to fill a Canvas with UIElements and save it as a tif image. However, my image is always blank. It is because the Canvas is never displayed on the screen and some sort of initialization and drawing never took place? How can I make this work? The Canvas creation would go something like this: ...

WPF - synchronous animation

I have something this: scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, shrinkAnimation); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, shrinkAnimation); MyDialog.Show(); The animations run correctly in parallel (x and y shrink together), but because BeginAnimation is an asynchronous call, the Show() method ...

WPF: Good key-handling design

I've recently started using WPF for developing my applications. Now I've come to a point where I need some tips on good design when it comes to key combination handling. This is what I'm using at the moment: private void Grid_PreviewKeyDown(object sender, KeyEventArgs e) { if (Keyboard.Modifiers == ModifierKeys.Control) { ...

WPF: Using an image converted to vector graphics in a XAML.

I converted image.png to image.svg using Vector Magic and then to image.xaml using svg2xaml, which according to this is supposed to work with Visual Studio. After adding image.xaml to the project and setting its build path to resource, I add the following line to my XAML file: <ContentControl Template="{StaticResource image}" /> Acco...

'Quick Text' editing like in MS word - WPF

I want a special TextBox (May be RichTextBox) in to which I need to type lot of text and predefined fields. When I enter a special char '[' I need to get a VS like intellisense popup and mark the inserted text in a special manner like below So please suggest me a way to make the inserted field selectable as in word. so the double clic...

Stream Video using WPF and .Net 4 beta 2?

I am trying to make a simple application that allows two computers to share video from their integrated webcams. How do I publish my webcams video and on the other end, retrieve it? Thanks ...

Binding WPF Toolkit DataGrid ComboBox column to Linq-to-Sql collection after Window loads and connection changes?

Hi All, I am a beginner to MVVM. The main window uses a stock DataGrid from the WPF Toolkit. It has one View Model and relies only on DataContext_Changed event handler in the .xaml.cs file. The main window's DataContext is the View Model. I am attempting to bind the ItemsSource property of a DataGridComboBoxColumn to a CLR property, "...