wpf

I changed the name of the WPF form and now it refuses to launch the application.

This is probably a very simple fix. I clicked the form in the Solution Explorer. Pressed F2 to rename it. Renamed it "MyForm.xaml". Pressed enter. Tried launching the application but I get this error: Cannot locate resource 'window1.xaml'. ...

How to Bind Two Lists to Two Columns of Wpf DataGrid?

I want to bind two lists to two columns of a Wpf DataGrid. How is this done in Xaml? Class MainWindow Public Property Column1 As List(Of Integer) = New List(Of Integer) From {1, 2, 3} Public Property Column2 As List(Of Integer) = New List(Of Integer) From {4, 5, 6} End Class ...

DataTrigger with Value Binding

Why this doesn't work? <Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Asset}" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=CurrentAsset}"> <Setter Property="B...

Accessing Application.Resources from a DLL

I defined a resource in App.xaml in Application.Resources in a WPF application (exe). I have a dll which will be referenced by the exe. In this dll, I have a Window that needs to use the resource defined in Application.Resources. How can I do this? ...

Organizing c# code into different files

Hi everyone. I've gotten to a point where my main code file is about a thousand lines long and it's getting un-manageable; that is, I'm starting to get confused and not know where to locate some things. It's well-commented but there's just too much stuff. I'd really like to be able to organize my code into different files, each with i...

Conditional XAML

For easy of development I'm using a ViewBox to wrap all content inside a Window. This is because my development machine has a smaller screen than the deployment machine so using a ViewBox allows for better realisation of proportion. Obviously there is no reason for it to be there on Release versions of the code. Is there an easy method t...

Puzzle - Dynamically change data template control from another data template

I have a DataTemplate that contains an Expander with a border in the header. I want the header border to have round corners when collapsed and straight bottom corners when expanded. What would best practice be for achieving this (bonus points for code samples as I am new to XAML)? This is the template that holds the expander: <D...

Iterating through StaticResource loaded by ResourceDictionary

Given a resource dictionary loading some static resources into memory - is there any way to iterate through theResources loaded into memory? My silverlight application keeps telling me it cannot find a static resource. I wonder if I have a naming convention issue or somehting - was hoping iterating through the resources in memory would...

WPF, ShowGridLines equivalent for wrap panel

I need to display a 1 pixel wide border around all wrap panel cells, kinda like excel grid. Unfortunately the wrap panel does not implement the grid ShowGridLines property. I can't put a border inside every cell because adjacent cells will have a 2 pixel border instead of 1 pixel. Since the wrap panel arranges it's layout dynamically and...

WPF Conditional Binding. Button.IsEnabled to SelectedIndex >= 0

I want to bind a buttons IsEnabled property to (myObject.SelectedIndex >= 0).... isn't there a simple way to do this in the xaml (without having to do crazy things to any underlying objects)? I haven't really seen a good example. Honestly, I wish this was as easy as Flex 3 ... I.E.: <mx:Button enabled="{dataGrid.SelectedIndex >= 0}" .....

C# WPF Slider Issue with IsMoveToPointEnabled

I have IsMoveToPointEnabled on for my Slider, so when I click anywhere on the component the selector moves to my mouse. The problem is if I have this option on and click and hold the mouse down to drag the selector the selector doesn't move. Anyone know how to fix this? ...

Binding Data Template element to property on sub-class

Hi guys, I have a class, for experiment sake call it foo() and another class, call it bar() I have a data template for class foo() defined in my xaml, but one of foo()'s properties is a bar() object such that foo() { Public string Name {get; set;} Public int ID {get; set;} Public bar barProp {get; set;} } and bar() ...

How can I force a ListView with a custom panel to re-measure when the ListView width goes below the width of the previous measurement?

Sorry for the long winded question (I'm including background here). If you just want the question, go to the end. I have a ListView with a custom Panel implementation that I'm using to implement something similar to a WrapPanel, but not quite. I'm overriding the MeasureOverride and ArrangeOverride methods in the custom panel. If I do...

Drop Item into Specific Index in ListView in WPF C#

I have a list of files in a ListView in WPF. Users can drag files onto the list view, and right now they are just appended to the end of the list. Is it possible to insert the file into the ListView right where the user dropped it? ...

Can you add items to a context menu in a parents menu?

or conversly can you import a parents menu items into a child window? So I have an UI that is composed of controls that all have their own context menu, but we also have a datagrid that get's nested inside our generic contaier. So when you right click the datagrid elements I want to show both the context items I've created for the da...

WPF DataGrid and Avalon TimePicker binding problem

I'm using a the WPF DataGrid from the wpf toolkit and a TimePicker from AvalonControlsLibrary to insert a collection of TimeSpans. My problem is that bindings are not working inside the DataGrid, and I have no clue of why this isn't working. Here is my setup: I have the following XAML: <Window x:Class="TestMainWindow" xmlns="http://sc...

Setting CommandTarget to selected control in a TabControl

I have a WPF window with a few buttons and a tabcontrol having a tab for each 'document' the user is working on. The tabcontrol uses a DataTemplate to render the data in ItemSource of the tabcontrol. The question: If one of the buttons is clicked, the command should be executed on the control rendering the document in the active tab, b...

Why do we need to use ConvertBack in IValue Converter

Hi, I am not sure Why we need to use I ConvertBack method in IValueConverter. In the Convert method itself we do the conversion and return the updated value to be bound in our control. So in which Scenario we should use Convertback. I know this question is very basic but just wanted to make the fundamentals clear. Thanks a lot for you...

How to access data from another datatemplate in wpf ?

Hi, I have 2 Datatemplates. One contain a grid , second one contain a button. I need to send command parameters of button as selected grid items. How can i do this ? <ObjectDataProvider x:Key="Datas" ObjectType="{x:Type ViewModel:UserControlViewModel}"></ObjectDataProvider> <DataTemplate x:Key="SourceGrid"> <WPFToolKit:DataGrid x:Na...

wpf data grid bug/error

Hi All, I m facing a problem with WPF DataGrid. I m using WPF DataGrid & DataGridTemplateColumn (textboxes) sometimes i get following error... whilst inserting data... i get error off and on... there is no pattern to reproduce error. it happens randomly System.NullReferenceException : Object Reference not set to an instane of an obj...