wpf

Dependencies of dependencies not being copied to the output directory

Hi, I posted this question on the MSDN forum but haven't been able to receive much of an answer, so decided to try it out here. I'm having a problem with dependency libraries of a project not being copied to the output directory of a second project that references it, when the first library is mostly xaml. Here is a typical scenario w...

WPF c# Context Menu Text Alignment

Hi, i am building a context menu for a WPF c# application and just for simplicity's sake, if i have text and then i add an image, the text is always aligned at the top of the menu items cell and i cant figure out how to align it to the center. i have tried the veticalalignment property and veticalcontentalignment property but they dont h...

Get the item doubleclick event of listview.

How to get the item double click event of listview? ...

Drawing using DrawingContext over elements on canvas

I'm drawing a selection box when I click and drag on my canvas object (which extends Canvas). I have overridden the OnRender method like so: protected override void OnRender(DrawingContext dc) { base.OnRender(dc); DrawGrid(dc); DrawSelector(dc); } private void DrawSelector(DrawingContext dc) { if (Selecting) { dc.Dra...

Binding TreeView to XML

Hi I recently got it working to bind my XML document to my treeview by doing the following in the code behind file: XDocument doc = XDocument.Load("path\\dsCurrent.xml"); _treeView.DataContext = doc; and the following in the XAML: <Window.Resources> <HierarchicalDataTemplate ItemsSource="{Binding Path=Elements}" x:Key="TVTe...

What use has RoutedCommand' class constructor ownertype argument?

The constructor of the RoutedCommand has "owner type" as a last argument. What is its significance? When it is used? MSDN documentation gives completely no clue about why it's needed and whether I could use one type for all commands Quote from MSDN ownerType Type: System.Type The type which is registering the command. The...

How to refresh a WPF DataGrid?

I have a WPF DataGrid with some data. You can add rows through a separate window. The DataContext is the same, a LINQ-to-SQL object. Binding is also the same, I bind the "ItemsSource" property to a table. In the other window, when the user clicks on "Save", I create a row programatically and add it using "InsertOnSubmit". After that I u...

How to give focus to and select text in a TextBox from ViewModel

I'm experimenting with MVVM in the context of a simple WPF app. I have a Command attached to a button. If the text in a TextBox is 'incorrect', I want the TextBox to get focus and all it's contents selected. It seems the only way to do this is either through some kind of direct call from the Command in my ViewModel to the View, or set...

WPF Vertical menu - showing first sub menu on left

I am currently trying to make the WPF menu render vertically. I used the following code : <Menu.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Vertical"/> </ItemsPanelTemplate> </Menu.ItemsPanel> which is ok but I would like the submenus to show on left of each root menuitem. any pointers on how...

Disable Multi-Select CheckBox functionality in a ListView?

I'd like to disable the multi-select feature of a checkbox in a ListView. How do I do that? ...

WPF Creating a ControlTemplate that is DataBound

I have a control bound to an Object and all is well but I want to turn it into a control template bound to different objects of a similar type. I would like to do this exclusively in xaml, if possible. Any good tutorials that outline the steps? <TextBlock Text="{Binding Source={StaticResource BorderControl}, Path=ControlName}"/> EDI...

Enable data binding in shared WPF resources inside a ResourceDictionary

I'm using the M-V-VM pattern in WPF and I have a background brush I'm going to be using rather often and I'd like to move it out in to a shared ResourceDictionary. The only problem is the brush uses a color which it gets via Databinding to its hosted context. Is there anyway I can move the brush out in to a ResourceDictionary and still...

How do I space out the child elements of a StackPanel?

Given a StackPanel: <StackPanel> <TextBox Height="30">Apple</TextBox> <TextBox Height="80">Banana</TextBox> <TextBox Height="120">Cherry</TextBox> </StackPanel> What's the best way to space out the child elements so that there are equally-sized gaps between them, even though the child elements themselves are of different sizes? ...

What should Binding Path property be set to?

Hi All, Assuming I have this struct definition in C#: public struct TimeSlotInfo { public int TimeSlotID; public int StartMin; public int CalcGridColumn; public string BackgroundCol; public bool ToDisable; } And I have a linq query as so: var TimeSlotsInfo = from ts in datacon.TimeSlots select new TimeSlotInfo { Ti...

WPF MenuItem children not showing

Hi, I am using an ObjectDataProvider and a DataTemplate to populate a MenuItem inside my Menu bar. (WPF, C#/XAML) See snipet below. Result: The top menu item appears, when i click on it, the wrapping menu item (the one with the bound header text) appears along with the little arrow indicating the presence of children but hovering or cli...

How to Move images from one place to another in a single listbox in a WPF Application

I have Developed a WPF application in which iam adding images to the listbox. Now i want to move the images from one place to another in that listbox. for example - image which is in first position in a listbox has to move some fifth postion my dragging with mouse pointer. Any suggestions plz. Thanks in advance ...

WPF Destructor

Does anyone know the correct method for writing a destructor for an XBAP application? ...

How to change the button color onmoveover,onmouseleave in wpf by using triggers or any other events.

I have developed a WPF Application with some buttons. Now i want to change the color of those buttons onmouseover,onmouseleave,onmouseenter by using triggers or any other events. Any suggestion plz Thanks in advance. ...

Using StackPanel as ContentControl (WPF)

So I have a StackPanel that I am using as a ContentControl. I have a place where I want buttons to be generated based on data that I am binding to, and that is all working good, but I want the buttons to be laid out horizontally, not vertically as is what is currently happening. Here's a screenshot: And here is the code from my Cont...

Compile Xaml into Baml?

How can I convert a xaml to baml? thanks ...