wpf-controls

How to load a UserControl in WPF with reflection?

private void Window_Loaded(object sender, RoutedEventArgs e) { var assm = Assembly.LoadFrom("wpflib.dll"); foreach (var t in assm.GetTypes()) { var i = t.GetInterface("test.ILib"); if (i != null) { var tmp = Activator.CreateInstance(typeof(UserControl)) as UserControl; this.stac...

wpf my UI doesnt refrash

my xml is : <Window.Resources> <Style TargetType="ListViewItem"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> </Style> </Window.Resources> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="381*" /> <ColumnDefinition Width="20*" /> <ColumnDefinition Width="101*"...

binding an observable collection with a combo box in a user control

Hi Experts, I have a combo box inside a user control and i am trying to update an observable collection with the change event of this combo box. This combo box has a list view inside it. I have added a working example of this scenario so you can copy paste it in your VS IDE. The user control in this example is just a part of the origina...

MVVM event - how and where in MVVM architecture they should take place ?

assuming i got this main window xmal: <Window x:Class="MVVMTUTRIALS.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:TestMvvm444.Views" Title="Window1" Height="300" Width="400" Loaded="Window_Loaded"> <Grid> <views:CustomersLi...

Draggable Canvas in WPF Using a 'Thumb'

Hi folks, On my quest to implement a very simple 'drag' mechanism to my application (which consists of multiple canvasses nested inside a 'parent' canvas) I've come up with the following bits of code: (Showing only the relevant bits to save space) MainWindow.xaml <Canvas Name="parentCanvas" Background="#FFE8CACA"> <Canvas...

How to expose ItemTemplate and ContentTemplate from a UserControl

I have written a Well control, similar to the Visual Studio editor tabs so that a user can have multiple documents open and can see one or more at a time. It is derived from a UserControl and exposes an ObservableCollection of OpenDocuments that binds to the ViewModel. If I were to implement this as a simple TabControl, then this would b...

Controls available on WPF tab are not getting displayed

I am new to WPF and facing some wierd issue. I have designed a screen having a tab control. Tab control has two tabs and each tab item has few controls on it. The issue is; When I open same solution from different machine I am not able to navigate between these two tabs in design time but on machine (on which I have designed screen) it ...

WPF: Select child control within a Canvas

Hi folks, A quick question regarding WPF: How can I select child elements within a Canvas/Grid? For example, in the following XAML snippet: <Canvas Name="parentCanvas" Width="200" Height="200" Background="AliceBlue" MouseMove="parentCanvas_MouseMove" MouseLeave="parentCanvas_MouseLeave"> <Border Name="border1" Margin="10" ...

How can I choose different DataContext for UserControl based on property?

I want to choose different DataContext for UserControl, based on what user specified in xaml, suppose I have a user control: public partial class UcMyControl : UserControl { public UcMyControl() { InitializeComponent(); if (Group == "Group1") this.DataContext = DataContextA; else if (Group ==...

How to focus a row in a WPF 4.0 DataGrid

I am setting the SelectedItem of a DataGrid in code behind, but this does not move the focus to that row. I have tried the following: dgEmployees.SelectedItem = emp; dgEmployees.CurrentItem = emp; dgEmployees.ScrollIntoView(emp); DataGridRow dgrow = (DataGridRow)dgEmployees.ItemContainerGenerator.ContainerFromItem(emp); dgrow.Focus(); ...

WPF Datagrid binding to ObservableCollection no columns generated

Hello, I am binding a datagrid to some data and using the AutoColumnGeneration. When using a regular linq query against a dataset, everything works fine : var queryAll = from actor in actorsAll select new { ActorName = actor.IsPerson ? actor.FirstName + " " + actor.LastName : actor.CompanyName }; MalatDetailsBudgetGr...

How to use string values in place of ticks on WPF Tickbar?

I wish to customize the appearance of the basic WPF TickBar. I was wondering if there was a simple way to do this using a control template: I wish to have numbers in place of ticks along the tickbar. I want the position of the number to correspond to the value of a slider (much like the picture in the link). I've searched around an...

Create a WPF text box which only responds to character key presses and few selected editing key presses

The WPF text box responds to quite a number of editing commands. I want to eliminate the vast majority and have it respond to any text input and few editing commands like backspace & delete. I know I can handle the KeyDown event but I can't see any easy way of distinguishing between character input and editing key strokes. ...

A tree-like, manipulable control for manifold hierarchical data

Hi folks, I am new to C# and WPF and I need to create a diagramming control similar to MS Visio but without direct user interaction. I have tree-like hierarchical data whose nodes can be of the same type. Quite like graphs whose vertices themselves contain graphs (i.e. vertices are subgraphs). I cannot use the Graph# library for several...

WPF TextBox template, how to explicitly define/position the selection element.

A TextBox template now contains only 1 named part, PART_ContentHost, that buries the text element and selection element to where it is no longer customizable. Our previous versions of this template had many more named parts and allowed us to explicitly define the selection border element. We want our selection to be underneath the text...

Irregular PNG button's click event in WPF

Hi, I need an irregularly shaped button in WPF. I am doing it in this way using XAML: <Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left="177" Canvas.Top="0"> <Button.Template> <ControlTemplate> <Image Source="ball.png" /> </ControlTemplate> </Button.Template> </Button> My ball.png image is a PNG ima...

Dragging a window in WPF using DragMove method and click handler on the same button.

Hi, I need a button for two purposes: - Users can drag the application's window using the button - Users can simply click the button to toggle visibility of some other element in the window. The button is a PNG image. I am trying to do it in the following way: XAML: <Button Name="toggleButton" Click="toggleButton_Click" Canvas.Left=...

How to draw arrows on a customized TreeView?

I have a customized TreeView which displays its content in form of hierarchical boxes inside a WrapPanel (based on http://www.codeproject.com/KB/WPF/AdvancedCustomTreeViewLyt.aspx). I only modified the template of the TreeView. Now, I need the following: I would like to freely position my nodes: Would you recommend to replace my WrapP...

MouseLeftButtonDown is not getting fired

I have a WPF user control that is dervied from UserControl class. MouseLeftButtonDown is not getting fired at all for the contol. I added event handler and also tried as follows. I guess it is handled somewhere else, how to debug and find where is it getting hanlded.. Any help is appreciated! protected override void OnMouseLeftButtonDow...

How to set Panel.Zindex value though XAML code if any of the Grid/UserControl children having the focus.

Hi, I think I have not explained correctly. So i have just edited the previous post. Please go through my exact requirement I have user control with a button. I have written code to enlarge the button if it gets focus through rendering in style. In my window, in the main grid i have placed 10 instances of this user control ( 1 contro...