wpf

how to open a WPF dialog from a WinForms menu

I have a WinForms menuitem and I need that on menu click the new WPF dialog is loaded. How do I do this? Thanks ...

WPF Trigger not working (sample)...

I have a custom WPF Line, that I whant to change the Style when selecting with mouse. I tried to use triggers(see code bellow), but this does not work. Where is the problem? The IsSelected property is changed, but the StrokeThickness does not change at all... ( XAML: <UserControl.Resources> <Style TargetType="stops:MyLine" x:Key...

OneWay binding for ToggleButton's IsChecked property in WPF

I have a ToggleButton with its IsChecked property bound to a property using a OneWay binding. <ToggleButton Command="{Binding Path=SomeCommand}" IsChecked="{Binding Path=SomeProperty, Mode=OneWay}" /> The SomeCommand toggles the boolean SomeProperty value, and a PropertyChanged event is raised for SomeProperty. If I change So...

Can a brush draw outside of an wpf element?

Hello, is there any possibility to draw outside of an wpf element with a brush, E.g. <Polyline StrokeThickness="10" Points="100,100 200,100 200,0"> <Polyline.Stroke> <VisualBrush > <VisualBrush.Visual> <Rectangle Stroke="Red" Height="500" Width="500"></Recta...

Basing A Style Off A Dynamic Resource

It seems something like this is not allowed. Any workaround? <Style x:Key=MyDerivedStyle TargetType="{x:Type Button}" BasedOn="{DynamicResource GlobalButtonStyle}" /> <Style x:Key="GlobalLabelStyle" TargetType="{x:Type Button}"> I get the error: A 'DynamicResourceExtension' cannot be set on the 'BasedOn' property...

how to add a WPF dialog to a Winforms project

Hi I am using Visual Studio 2008 targeting .net 3.5 framework. I need to add a WPF dialog to a Winforms project. I was thinking that by adding reference to PresentationCore, PresentationFramework and WindowsBase.dll and copying a WPF dialog from a test WPF project to the WinForms project in question should do the trick, but after that wh...

WPF - Build a string of pressed keys using KeyDown in ListView

I have a listview with a dozen of rows binded to xml. I'd like to have a possibility to locate and position the cursor to a certain record. For example: I have a with these ID, Name, Value: 1, Johny, Cash, USA 2, Jean-Michel, Jarre, France 3, Jeanette, , USA When I would type "Je", the SelectedRow would be positioned to ID 2. When I w...

Detect when drive is mounted or changes state (WM_DEVICECHANGE for WPF)?

Hello, I am writing a directory selector control for WPF, and I would like to add/remove a drive from the directory tree when it gets mounted or unmounted or when it becomes ready or not ready (e.g. the user inserts or removes a CD). I am looking for a system event similar to WM_DEVICECHANGE. konstantin ...

WPF: How to walk up the Visual Tree to find a Model3DGroup a clicked 3d-model is in?

I'm displaying a few 3D-models as Model3DGroups. They are surrounded by Viewport3D which catches MouseDown-events. I want to determine which Model3DGroup (they all have names) was clicked. I'm starting with this: Point location = e.GetPosition(karte.ZAM3DViewport3D); HitTestResult hitResult = VisualTreeHelper.HitTest(ka...

WPF datagrid : how to sort a column programatically ?

Hi, How do I sort a column programatically ? I would like to have a function such as myWPFDataGrid.Columns[0].Sort(..) MadSeb ...

Visual Studio 2008 - Program exits immediately with F5 (start debugging)

I'm having a strange issue with Visual Studio where if I start debugging it exits immediately. This started happening after changing the assembly name in the project properties. If I change the assembly name back to the previous name then the program runs fine. How can I fix this? Here is the output when running after changing the assem...

WPF MVVM Button Control Binding in DataTemplate

I've seen other questions that deal with this, but never any explicit code describing the fix. I can't get a button inside of my ItemTemplate to bind to ANY command anywhere. Very frustrating. I am a complete MVVM newbie, btw. Here's my Window XAML. <Window x:Class="RET.CMS.Printing.App.MainWindow" xmlns="http://schemas.microsoft.c...

How to access x:Name-property in code?

I assigned x:Name in my XAML-file to a object which can trigger a MouseDown-event. In that event I'd like to get the x:name-attribute of the sender again. How do I do that? The object looks like that: <ModelUIElement3D MouseDown="ModelUIElement3D_MouseDown" x:Name="trololo"> ...

WPF: Best way to get a snapshot of what is under a Canvas control

Hi, I have a WPF app, and I use a Canvas with 50% opacity as a cropping rect that can be resized and moved over an Image, and every time it moves, I use a CroppedBitmap to show a live preview of the image, but it makes the app become slow as I create a new CroppedBitmap every time... What's the best way to get an image of the area the C...

Building a DataTemplate in C#

I am trying to build the following DataTemplate in C# <DataTemplate x:Key="lbl"> <!-- Grid 2x2 with black border --> <Border BorderBrush="Black"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefin...

WPF Is it legal to invoke another event from within an event-invocation-method.

The following code was part of an answer I have received to solve a probem I have posted in SO. It works fine, however I'm curious if its allowed to manually invoke another event from within an invocation-method with the EventArgs of the original event: protected override void OnMouseLeftButtonUp( MouseButtonEventArgs e ) { ba...

Visible Binding Based On Bound Object and Model Properties

I ran in to the unique situation today where I needed to bind the Visible property of a button in a DataGridRow to be based on both a property of the bound object and of the model backing it. XAML: <t:DataGrid ItemsSource="{Binding Items}"> <t:DataGrid.Columns> <t:DataGridTemplateColumn> <t:DataGridTemplateColum...

Drop-down TabControl

I've been trying to create a custom skin/template for a TabControl in WPF. I want the tabs to be displayed in a ComboBox. When you select the item from the ComboBox, I want the content area of the tab control to display the TabItem contents. Here's an image showing what I'm looking for: I could do this using some sort of master-deta...

AvalonDock : Controling the Splitter position

Hi, Using AvalonDock and Odyssey OutLookBar in a WPF Desktop application. It doesn't make sense to have the vertical splitter in the ResizingPanel have full range of screen width. ResizeWidth as an attached property on the DockablePane does control the initial position. But then it can be moved from full left to right. Is there any way o...

WPF Disable the item selection on MouseMove of a ListBox

If I press the mouse on an item of a ListBox and then move the mouse without releasing the mouse-button over another item, the selection automatically changes to the element that is under the mouse. Is there a possibility to disable this behaviour, so that the selection is only changed when the mouse has been pressed directly over the ...