wpf

In XAML, what "guidelines" should I use when deciding whether or not a property should go in a style?

When writing WPF/Silverlight applications, I sometimes struggle when determining whether or not a property should go inside a style or be left directly on the element. What guidelines do you use when deciding? ...

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...

WPF binding XML data to GUI items

I'm new to WPF and don't yet have a solid grasp of how things should be done... I have an xml file that stores config data and I want the data that is in this xml file to be displayed on the gui front end. I'm currently using an XmlDataProvider that reads in a set of data The data is roughly like: <Items> <Item name="item01"> ...

XAML - Convert Value to Specific String?

Hey all, This should seem to be a fairly straightforward question, but I'm struggling a bit. I have a collection of objects that's I've bound to a Grid aling with a Series of GridViewColumns for each property of the object I'd like to display. One of the columns, however, is currently displaying as an int and I'd like to convert it ove...

How to bind the Itemcontrol

Hi, I have Itemcontrol <ItemsControl ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <Border BorderBrush="Red" BorderThickness="1" Background="Blue"> <TextBlock Text="{Binding Text}"/> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsContr...

Execute a usercontrol command from a viewmodel

I have a usercontrol with a command, what I would like to do is execute this command from the containing view's ViewModel. This would be easy to accomplish in the code behind, as I could just go "UserControl.MyCommand.Execute", but of course I want to be able to do this in the ViewModel. In theory, what I would like to do is bind the U...

In a local WPF Web Browser Application how do I write to a file? Sandbox doesn't allow?

Hi, So I have a local WPF web browser application and I need it to write to a text file. However I always get the an exception of type System.Reflection.TargetInvocationException. I don't get any more information but I'm pretty sure it is because it is being run from a web browser (security etc.). The code I am using works in a regular...

Working effectivly with HTML in embeed web-server inside a .net/wpf-app

Hi, I have a pretty complex composite application (.NET/WPF/Prism). It runs on some kind of embedded devices (with full fledge window 7), let's call them "kiosks". I need to allow remote control for the applicaton. i.e. it should have an embedded web-server which will provide some information via http/html for remote control (checking st...

WPF MVVM service layer

I plan on writing a WPF app following the MVVM pattern for the first time but something is not quite clear to me. Let's say that the view has a "Save" button and when that is hit I need to save the current state of my data (the model). This will be done by sending a SOAP message to a SOAP service. Where in my MVVM setup do these SOAP ...

Problem with BitmapFrame rendering (created from byte array) in C#

Hi there, Here is the situation: I have got the array of bytes containing the bitmap header together with the bitmap data. I know the offset of data, and I need to generate BitmapFrame for later rendering. I wanted to avoid array cells copying and created a wrapper for a part of the array ( ArraySegment ). Then I render this bitmap...

What is the WPF equivalent to "System.Windows.Forms.Application.X" for obtaining startup path, app data path, etc.?

I'm converting a windows forms application to a WPF application. Is there a way to obtain things like, Startup Path, User App Data Path, Common App Data Path, etc. without referencing System.Windows.Forms? Previously, I used System.Windows.Forms.Application.StartupPath, but the System.Windows.Application.Current object doesn't contain ...

Breaking out of the Data Binding hierarchy

Hey all, I'm kind of new to WPF, and I'm trying to do some specialized data binding. Specifically, I have a DataGrid that is bound to a collection of objects, but then I want the headers of the columns to be bound to a separate object. How do you do this? I have a couple of classes defined like so: public class CurrencyManager : INot...

CanExecute method going to false problem

Well, in our application this usually works fine. But at some point, none of the CanExecute methods fire (even if I explicitly call CommandManager.InvalidateRequerySuggested(), the CanExecute methods don't run). Anyway, despite the fact that they don't run, they all get set to false, so every button, menu item, etc, bound to a CommandBin...

Using custom class in XAML so it's properties serves as binding destination

First of all sorry for my "pidgin" english, :( Application was built on MVVM pattern. ViewModel exposes its functionality via commands & has special command - DispatchCommand which receives (in CommandParameter) pair of other Command/Parameter & executes received Command with received Parameter. The feature (rather unimportant for topic...

Generate a specific color for each string?

I have a DataGrid that shows orders that belong to product. I want to have a generated SolidColorBrush that is unique to each product. Update I need these colors to be solid and distinctive, or at least to be ordered in a distinctive way, i.e. there shouldn't be black, blue, green as these 3 colors can be confused with each other. Bes...

WPF background worker need a dispatcher for bound data

I have all my data bound from WPF controls to properties in an object that my Window can access. When I run a backgroundworker thread, do I need a dispatcher to access these underlying properties, or since I'm not explicitly accessing the UI controls, is that handled automatically by the mechanism binding the XAML to the code properties...

Is there a .NET list of 256 colors only?

The Colors class exposes too complicated properties (i.e. beige and other column I don't need). I only want a list of the main colors, or at least the list should be ordered by extremeness, i.e. should first contain the explicit colors like black, white, red, green, blue, then should go to more complex combinations like yello, orange, p...

WPF: Databinding a dictionary property

I have a UserControl with a property of type Dictionary, called HighlightedDates. The property holds a set of dates, with a tool tip string for each date, and it works fine when set from code. I want to bind the HighlightedDates property to a view model property, DatesWithNotes, of the same type, using this markup: <MyControls:MyCalen...

Fetching playlists from Windows Media Player throwing non-descriptive exception

I’m building a WPF application that needs to interface with Windows Media Player. Before making a call to get all my local playlists, I initialize the media player like so: Type mediaPlayerCoreType = Type.GetTypeFromCLSID(new Guid("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")); _mediaPlayerCore = System.Activator.CreateInstance(mediaPlayer...

Make WPF Application Fullscreen (Cover startmenu)

I would like to make my wpf application fullscreen. Right now the start menu prevents it from covering everything and shifts my application up. This is what I have for my MainWindow.xaml code: <Window x:Class="HTA.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.co...