wpf

wpf manually generate TreeViewItem container

I am creating a TreeView at runtime. It has several nodes(TreeViewItem), each one having a name. Initially it is collapsed. A separate comboBox displays Names of all TreeViewItem. I have to highlight a TreeViewItem based on the Name selected. I am using a recursive function and gets the TreeViewItem container like this: if (parent.ItemC...

Creating a ViewModel : do it before or after model data is available?

I have a WPF application that loads data from a data source. Until some data is loaded there is nothing to display. My question is do I: Create both V and VM before any data is available; set the data in the VM once available Create only V at the start; wait until data available then create the VM injecting the data Create both V and...

Binding a slider value on the height of its thumb in WPF

Hi, I have a databinding problem in WPF. I would like to "customise" a slider in a way that the thumb grows when you move the slider to the right and the thumb shrinks when you move the slider to the left. So I edited the template for the slider and changed the look of the slider so the slider looks like I want it to. But now I have ...

WPF XAML StringFormat: Culture Workaround broken in C# 4.0?

The work around... FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); ...used to work till now (mentioned here: http://stackoverflow.com/questions/520115/stringfomat-localization-problem/520334#520334)....

Capture a keyup event at application level in WPF

Hi I have an application built in wpf. At the base level I have a usercontrol and on that usercontrol are many components. I want to be able to capture a key press event on my usercontrol even if the focus is on one of the children. Using PreviewKeyUp doesn't seem to do the trick. Thanks, Matt. ...

Looking for a standard way to manage documents in a WPF application

Hi! I'm writing a WPF application that uses one document at a time. Is there any standard way to implement the management of the current document? What I mean are the following functions: New document: if there are not saved changes in the current document, a dialog box opens ('Do you want to save changes to {0}?') with Yes/No/Cancel ...

WPF DataGrid gets wrong height when used with RowDetails

I have a problem with the new DataGrid component that comes with .NET4. The problem occurs when using RowDetails. With RowDetails the total height of the grid is increased when an element is chosen. This is necessary to show all Rows and the RowDetails, and exactly what I expect. When choosing another row the first RowDetails will collap...

windows application user control in wpf

Hi Experts, I have created a user control in windows application and used it in wpf. The user control is in a seperate project and solution than that of wpf. I have exposed some properties in the user control and tried to use it in a wpf form. I have used it in the WindowsFormsHost element and also added WindowsFormsIntegration refer...

How to read a Dependency property from a method

XAML: <my:Control ItemsSource="{StaticResource MySource}" A="true" /> Assume a Control with a dependency property A with a default value false; and a method to handle the Source Collection: protected override void OnItemsSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue) {} in which you...

difference between datagrid and grid in wpf

hello, Can anyone tell me the difference between DataGrid(not GridView) and Grid controls in wpf? Thanks ...

WPF MVVM KeyBinding not being recognized right away and not always working

For whatever reason, the KeyBindings for my UserControl aren't working as soon as my WPF Application loads. They do work after I press a button on the form but not when I set focus to the form by clicking or alt tabbing or moving or anything like that. And when they do work my enter keys print a random number. (sometimes 5, sometimes 7 e...

WPF, how can I optimize lines and circles drawing ?

Hello ! I am developping an application where I need to draw a graph on the screen. For this purpose, I use a Canvas and I put Controls on it. An example of such a draw as shown in the app can be found here : http://free0.hiboox.com/images/1610/d82e0b7cc3521071ede601d3542c7bc5.png It works fine for simple graphs, but I also want to b...

how to template a listview item / wpf

I am trying to achieve this using Expression Blend 3. I need that every listview item to contain an image, followed by a text. ItemTemplate doesn't seem to work. Thanks ...

How do I Show/Hide a Grid Row and Grid Splitter based on a Toggle Button?

Currently I have a toggle button that is bound to a boolean property (DualLayout) in my code behind. When the boolean is set to True, then I want my second row in my grid (and grid splitter) to hide and have the first row take up the entire space of the grid. Once the boolean is set to False, I want the grid splitter and bottom row to ap...

Freezable DataContext

Hi, I have a customControl like ListView and I need to bind the sub property of my Custom Control to the visual tree element like below, <StackPanel> <TextBlock Text="Test" x:Name="txtBlock" /> <local:MyControl> <local:MyControl.Items> <local:MyControlItem Value ="{Binding ElementName=txtBlock, Pa...

WPF DataTemplateKey can not find ListBox key

I am fairly new to WPF and am having trouble getting the DataTemplateKey to find my ListBox. <Window.Resources> <ControlTemplate x:Key="FocusTemplate" > <Rectangle Fill="Azure" Width="290" Height="55" /> </ControlTemplate> <Style x:Key="FocusStyle" TargetType="{x:Type Control}"> <Setter Property="Template" V...

Dependency Property WPF Grid

Hi All, I want to Bind the textblock text in WPF datagrid to a dependency property. Somehow, nothing gets displayed, but when I use the same textblock binding outside the grid, everything works fine. Below is my code, </Grid.RowDefinitions> <StackPanel Grid.Row="0"> <toolkit:DataGrid Name="definitionGrid" ...

WPF suppress load of databound text field on init form

Is there any way to defer the databinding until a field is changed for the first time? So basically, when the app first loads, I want the numberic textboxes to be blank instead of all being 0. Total WPF n00b here so please change the title if there is a better way to describe the problem! ...

MVVM View-First Approach How Change View

Hi everybody, Does anybody have an idea how to change screens (views) in a MVVM View-First-Approach (The view instantiates the ViewModel: DataContext="{Binding Source={StaticResource VMLocator}, Path=Find[EntranceViewModel]}" ) For example: In my MainWindow (Shell) I show a entrance view with a Button "GoToBeach". <Window> <DockPa...

Multiple WPFPreviewHandlers in One Window? Can it be done?

Here is the scenario. I am building a part of my desktop app up and I have a need to create a preview handler. I found plenty of examples on the web of a WPF Preview handler, but I wanted to go one step more than just that. Lets say we have multiple documents and I wished to compare them. So the ideal scenario would be able to see docu...