wpf

How do I create a WPF Image control that sources its data from a JPEG I've read into memory?

For the images in my application, I have been setting the source property of my image to a JPEG file on disk but, as part of my next iteration, I want to test keeping them in memory for speed. How do I tell the WPF Image control to get its information from an in-memory source rather than from a file? ...

How to Collapse / Expand multiple Expander controls depending on Group name in WPF?

What I want to achieve: To collapse or expand all Expanders that share the same group name within a group style. We have a ListBox and another ListBox nested inside it to display child items. The child items ItemsSource is bound to a CollectionView with Group descriptions attached. The group item template is quite simple: <Expander Is...

WPF: WrapPanel in ItemsPanelTemplate expands list width

Hi, I have a listbox defined like this: <ListBox.ItemTemplate> <DataTemplate> <ItemsControl> <!-- Contents here --> </ItemsControl> </DataTemplate> </ListBox.ItemTemplate> </ListBox> My problem is this: This l...

Inject toolbar into another view

I'm using mvvm for my new project. I have a message dispatcher to send messages between viewmodels but in one case I have to receive messages in a view. This view contains a toolbar panel that must contain the toolbar related to detail view (example editing a customer needs a toolbar with Save, Undo, Redo, Cancel). The problem is that I...

How to get the Curent Height and Width of the Browser

Hi, How can I get the Height and Width of the Browswer . I tried using : double Width = (double)HtmlPage.Window.Eval("screen.availWidth"); double Height = (double)HtmlPage.Window.Eval("screen.availHeight"); But this Returns the Current Screen Resolution. But I need to handle Some Controls like Media Element Height and Width When t...

WPF does not respect SQL Connection and Membership Provider in App.config

I have a WPF form that I am trying to use with a SQL Membership Provider we have setup. My App.Config looks like this: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <clear/> <add name="IodConnString" connectionString="server=SQLSERVER;UID=USER;PWD=PASSWORD;DATABASE=DATABASE;" providerName="Syst...

TreeView of many types with Master/Detail edit problems!

I have a TreeView wich has many types of items but they all inherit from a base class. Besides the TreeView there is a MasterDetail view for the selected item. Below the MasterDetail view I wan't to have a edit button that changes the MasterDetail view into edit view. I'm doing this by having the master detail view as a ContentPresente...

Have a WPF Control Class being a template class

Hey, is there a way to have a WPF UserControl Class to be a class with a Template type? e.g. public partial class MyControl : UserControl should be: public partial class MyControl<MyData> : UserControl as I always get compile errors that MyControl than has no reference to InitializeComponents which is in the automatic generated pa...

Can we drop a file in windows explorer from WPF window?

I have a treeview that shows the current file system. I want to add functionality to enable dropping files into windows explorer. If I drag any of the node of my treeview and drop it on any of the window of Windows explorer then the file will be copied to that location. How can I accomplish this? ...

Convert ContentPresenter to TextBox in wpf

I have a test project which bases on : http://thejoyofcode.com/ViewModels_and_CheckListBoxes.aspx I want display field of object, not entire object. How to convert this <ContentPresenter Content="{Binding Value}" Margin="1"/> to this <TextBox Text="{Binding Path=Name}"></TextBox> and still have a object :) <Window x:Class="WpfA...

WPF, WVVM, Databinding, and ResourceDictionaries

I've got a View (MainView) which contains a kind of main content area (MainContent). The View is backed by a corresponding ViewModel (MainViewModel). The main content changes, of course, based on the current state of the application and is represented in the ViewModel as a property (CurrentPrimaryViewModel). The content of MainContent...

Master/Detail in separate viewmodels?

I am designing a master/detail view. Currently, I have a user control (detail) in my main view, and both have thier own vm. On the one hand, I think there should only be one vm because the detail will never exist without the master. It would also be easier to handle the CRUD process in one vm because of their tight dependency on one anot...

Binding to Image Property

Let's say I have the following dummy class: public class Foo { public Image MyImage { get; set; } } and I have the following in some XAML <Image Source="{Binding Foo.MyImage}"/> If I understand this correctly, this doesn't work because Source is expecting a URI string value fo...

WPF Thread: "COM object that has been separated from its underlying RCW cannot be used."

I am getting following error: "COM object that has been separated from its underlying RCW cannot be used." I am sure the problem is because COM object is being called not on the thread it has been created - STA. I tried to implement IDisposable but it has not worked for me. There is a couple of posts dealing with similar problem but ...

Resolve this error

Hi, I have a WPF UserControl that i am using in a Windows Form using ElementHost. I am passing data from my Winform to my UserControl using a ListCollectionView. In my UserControl i have a method setdataSource where i am setting the datasource. But i keep getting this message in the output window when i debug my program "System.Wind...

How to assign a datatemplate to textbox wpf

Hi, TextBox is supposed to show masked dollar amount for certain access privileges. I created a converter class(inheriting from IValueConverter) to handle masking by implementing the convert method. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) The third parameter is p...

Should I use WinForms or WPF for taking pics with webcam?

We have a Logitech web cam that we want to get working with .NET. It needs to recognize the device, and be able to take a picture. We just installed VS 2008, and I was wondering if Microsoft made it easier to interact with devices with some of the newer stuff like WPF, Silverlight, or whatever. If anybody can point me in the right dir...

How can I prevent the grid splitter from resizing a column outside of the window bounds?

I have the XAML shown below (for example). If you drag the grid splitter as far as it goes to the left, and keep dragging the mouse, the right-hand column will grow in size outside the bounds of the window - obviously not what I want. The problem is that I can't set a hard MaxWidth on the right-hand column because the user can resize th...

Is there a way to convert an observable collection to a List?

I've got a test collection setup as : ObservableCollection<Person> MyselectedPeople = new ObservableCollection<Person>(); public MainWindow() { InitializeComponent(); FillData(); } public void FillData() { Person p1 = new Person(); p1.NameFirst = "John"; p1.NameLast = "Doe"; p...

WPF binding StringFormat syntax

How can I format a decimal value conditionally in a WPF window? Value should be rounded to a whole number (Ex: 1,234) When the value is 0.00, it should display as a single zero. (Ex: 0) Currently I use bellow mark up to format the decimal value, but it displays 00 when the value is 0.00. Please help. <TextBlock Grid.Column="6" Paddi...