wpf

WPF Datagrid SelectionChanged event is triggering Multiple times while loading the rows.

Hi, When i use DataGridComboBoxColumn in my WPF DataGrid, the DataGrid SelectionChanged event is triggering multiple times based on the number of rows while loading the rows in the WPF DataGrid. How can i stop this? Because of this I am facing Performance issue. ...

Question on EventHandler from Josh Smith's MVVM sample application

The following code is from the MVVM sample by Josh Smith: /// <summary> /// Raised when this workspace should be removed from the UI. /// </summary> public event EventHandler RequestClose; void OnRequestClose() { //if (RequestClose != null) // RequestClose(this, EventArgs.Empty); EventHandler handler = this.RequestCl...

Constraining item heights in WPF ListBox, with indicator

I have a ListBox control in WPF which contains items of variable height (predominantly a large text block, so it's also affected by word wrapping). Since scrolling behaves badly when the height of an individual item gets too high (especially when close to the height of the ListBox itself), I want to constrain the max height of the indiv...

How do I stop my ViewModel code from running in the designer?

I'm developing a networked WPF application with the MVVM pattern and it seems that it's running and connecting to servers in the designer. I know about the IsInDesignMode property, but I'm not sure how to access it in a ViewModel. ...

multi-column, editable TreeView in WPF

Yeah I am looking for some C# code of a multi-column TreeView where each cell can be inline-edited and also dragging the rows is supported. Do you have any good examples of such a custom component? ...

WPF Component in Windows Application

Hi all, i have created one component in WPF. its working fine with WPF but when i tried to use it in windows application i am getting one issue. i have one textbox in that control so in when the control hosted in windows applicaion and i try to type something in that textbox its not working. i tried to put some messageboxes in "KeyPrev...

XAML and local variable/auto property...

Hi all, I try to set a local property through XAML and a trigger. The idea is to "reproduce" the behaviour that exists in most of settings pages with an "Apply" button at the bottom. As soon as the user modify one the the control/settings in the page, I want to set a local variable ("FilterModified") to "true". I tried this, but somehow,...

[WPF] How can I force a textBox in wpf to call OnLostFocus in a unit test?

I have a custom component created in WPF using C#, where I have some validation that are checked when the textbox OnLostFocus is called (it is only when the user leaves the textbox I can do the validation, since only then do I have the complete input string to validate). How can I trigger the OnLostFocus on the textBox from the unit tes...

Error Cannot serialize a nested public type. why?

In the performance of this code is an error Cannot serialize a nested public type 'System.Windows.Forms.AxHost+State'. FlashControl my usercontrol <UserControl x:Class="Adminka.UserControls.FlashControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/win...

How to show a WPF window from a public static method in a Class Library project (dll)

I want to use WPF windows in future applications instead of Windows forms. The current setup is as Class Library Project with a public static method. I have added a Windows Form item to the Project. In the public static method I create an instance of the Windows Form Class and use the method ShowDialog. The reason why I use this setup ...

Strange WPF Thumb Cursor behavior

hi there, i´m currently facing a strange behavior with Cursors on WPF thumb controls. i have a thumb with a multibinding on the Cursor property that changes the cursor depending no the thumb´s rotationtransform angle. This works fine when i hover the mouse over the thumb. however, when i press the mouse (to do some transform) on the thu...

Determine what is blocking UI thread

Hi All I am working on a rather large .NET WPF real-time application. The application is working great and as expected, except for one BIG issue - UI Update is slow. This application is highly event driven, there are events raised all over for all sorts of things - through these events the UI is updated. One or many of these events is...

In WPF how to animate X property of the UIEllement from the code behind?

I want to animate the rectangle x position from my code behind (as the x position is only determined at the run time). I have got the following code: KeySpline easeOut = new KeySpline(0, 1, 0.3, 1); Storyboard sb = new Storyboard(); DoubleAnimationUsingKeyFrames da1 = new DoubleAnimationUsingKeyFrames(); SplineDoubleKeyFrame keyFrame1...

Undefined Enum & WPF ComboBox & WCF Serialization

I'm having problems finding a general solution to deal with Enum fields on WPF and WCF, I need a little bit of help. Let's explain with an example: When creating a person with a Sex enum value [Male, Female] I see three posibilites: Male is default -> There are two posibilities but one is default. No problems binding the ComboBox....

Lock all controls except one without changing their appearance

Hi everyone! I need to Lock all controls of my window except one, if I write Me.MainGrid.IsEnabled = False I obtaind the result but many controls change the appearance. I need they maintain the current appearance, like when I open a WinDialog with ShowDialog. To redefine the style af all controls is a too much "chinese" work. There is ...

Customize rounded corner radius of a WPF polyline

Hello, is it possible to set the corner radius of a WPF polyline to a custom value. For a WPF border it is possible. In my opinion, the polyline can only set StrokeLineJoin="Round", but not the radius: <Polyline Points="0,0 0,100 200,100" StrokeLineJoin="Round" /> For border: CornerRadius="..." is possible: <Border CornerRadius="8" ....

Use DataTemplate in WPF with a mocked object.

I have following xaml code: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding MainWindow, Source={StaticResource Locator}}"> <Window.Resources> <DataTemplate DataType="{x:Type vm:...

wpf twoway binding and update from code-behind...

Hi, I've ToggleButton defined like this in XAML: <ToggleButton IsChecked="{Binding DateFilter, ElementName=myUserControl, Mode=TwoWay}"/> and 'DateFilter' defined like this: public Boolean DateFilter { get; set; } When I click the toggle-button, 'DateFilter' updates accordingly. BUT, if I modify 'DateFilter' in code, the ToggleB...

How data driven applications are built generally

I am a newbie .net programmer learning WPF for past one month. One thing I am confused from the start is how real time data driven applications are built. I started with a basic application where I required to bind data to a datagrid which would have some 10 columns approxly. The common way of data binding I have seen in all the tutorial...

Center a polygon within a Grid control

Hello, Can anyone tell me how to center a polygon object within a given row/column of a Grid control? The example that I have tried is taken from msdn. <Grid x:Name="LayoutRoot" > <Polygon Points="300,200 400,125 400,275 300,200" Stroke="Purple" StrokeThickness="2" HorizontalAlignment="Center" ...