wpf

Porting a console application to WPF

I have created a small chatting application in C#, and started as a Console Application. However I want to create a GUI for it using WPF. It's a class named DanMessengerClientwith functions such as InitializeConnection(), SendMessage(string msg), etc. I have already designed the UI in Visual Studio, and it created it's Window1 class on ...

WPF OpenFileDialog with the MVVM pattern?

I just started learning the MVVM pattern for WPF. I hit a wall: what do you do when you need to show an OpenFileDialog? Here's an example UI I'm trying to use it on: When the browse button is clicked, an OpenFileDialog should be shown. When the user selects a file from the OpenFileDialog, the file path should be displayed in the text...

DataTemplate at design time

In one of my first attempts with WPF I went a bit too far: I have an object that needs a different DataTemplate depending on one of its properties. In other words if (object.property=="multi") then the template should be a combo, etc. Now I 've went ahead and obviously used a DataTemplateSelector to apply the required template. And in ...

WPF Binding Problem

I have this object: class a { public string Application; public DateTime From, To; } And I declare this list with it: ObservableCollection<a> ApplicationsCollection = new ObservableCollection<a>(); In my XAML I have: <ListView Height="226.381" Name="lstStatus" Width="248.383" Horizo...

How to add a StringFormat to a Textblock inside a DataTemplate?

I have the following datatemplate: <DataTemplate x:Key="ColoringLabels"> <TextBlock Padding="0" Margin="0" Name="Username" Text="{Binding Username}" Foreground="Gray" FontStyle="Italic" /> <DataTemplate.Triggers> <D...

WPF Routed events firing?

I have a WPF form with 3 buttons and have routed events on them, commands are binded on start... private void InitCommandBinding(UIElement frameworkElement) { CommandBinding commandBinding; commandBinding = new CommandBinding(ViewModelCommands.Save, Save_Executed, Save_CanExecute); frameworkElement.CommandBindings.Add(com...

WPF ListView/GridView single selection bug

There is a strange bug in ListView/GridView in WPF when the SelectionMode is set to Single. Ways to reproduce: Generate a collection (the collection must have enough items so that the ListView can at least scroll 2-3 pages): var customers = from c in _db.Customers orderby c.Name, c.City select c; Bind the collection to the ...

how to express this xaml combobox data-binding in c# code

ItemsSource="{Binding Source={StaticResource stringResources}, Path=MyProp}" I tried and got so far but I don't get it compiled: comboBox.ItemsSource = new Binding { Source = new StringResources(), ElementName = "MyProp" }; comboBox.DisplayMemberPath="Value"; comboBox.SelectedValuePath="Key"; It says that it cannot convert Binding t...

Changing the width of Window when using pages in WPF

Hi Im using pages in the WPF project that im currently working on. However i can't seem to figure out how to change the width of a page, or rather, the width of the window that hosts the pages? Setting the page width property only changes the width of the page inside the window frame. Setting the with of the mainwindow or navigationwi...

WPF : Automatic controls sizing

Hellow. I'd like to know if there were a kind of automatic control sizing in WPF. I mean, a way to auto size element regarding to the user's screen resolution, without having to define it in the code. thanks. ...

Google Chrome / Windows 7 effect on WPF?

Hey guys.. Windows 7 windows naturally have a semi-transparent header. What I just realized is that Google Chrome TabBar blends with this effect as if the TabBar background and the window header was the same thing! pretty much cool! Is there a way to have the same result with WPF? Any example? Thanks. ...

Why isn't Expression Blend rendering my User Control? It's only showing XAML.

I'm opening valid XAML within my VS2008 solution in Expression Blend 3 and it is only showing XAML when I try to open individual XAML files. My solution/projects all build and run correctly. When I go to View -> Active Document View the Design View, Split View and XAML View options are all grayed out... which doesn't make much sense. I...

WPF d3d9.dll crash

I have several applications in WPF that periodically crash on 2 different servers (a dell poweredge and a HP proliant). The problem is that the WPF applications both crash within d3d9.dll. Rebooting the servers always fixes the problem. The problem only occurs a few times a month. Both servers are running Windows XP instead of Windows 20...

How can we show .rtf or .doc as flowdocument in WPF?

Hi, It is for the help section of the application. I am thinking to put flowdocumentReader to show the help document. But is it possible to show .rtf or any .doc to show in Flowdocument.Or is it neccesary to create a flow document in Xaml. Please help. Thanks, ...

How to goto particular page number in flowdocument reader through code in WPF?

Hi, There is a pagenumber property in flowdocument reader.But that property is readonly. Is there any way to goto particular page number in flowdocument reader.Please help. Thanks. ...

How to go to particular topic in a flowdocument in WPF?

Hi, How do we have the topics listed from the flowdocument? and how do we go to particular topic in a flowdocument. Please help. Thanks, ...

C# program selected Event how in code

Hi iam trying to progam an listboxitem Selected event in code because i need dynamical listboxitems.Iam coding this in wpf it works great. <ListBoxItem Tag="cPage_Mod_Modules" Selected="ListBoxItem_Selected"> <StackPanel Orientation="Horizontal"> <TextBlock Style="{StaticResour...

Using winforms default exception handler with WPF apps

For simple 'internal use only' apps, Winforms has a useful default exception handler, which allows an 'ignore', and tells you what the exception was. WPF apps don't seem to get this nice exception handling - you always have to exit the application. Obviously I can write my own default exception handler for WPF, but is there a simple ...

How can I bind dynamic resource key value with column value in data table in wpf

Hello, I am developing a user control in wpf where I need to set eclipse background color as per value in database. Now that field contains values between 1 to 6. now I want that according to values in of that field my eclipse should have different color. I have defined 6 different brushes in resources. Their key values contain 1 to 6 n...

Problems loading WPF image in code, where am i going wrong?

Hello, I have an image in my xaml as so: <Image Name="TotalFloors" Width="98" Source="../Images/FloorOne.png" Margin="0 0 0 10" VerticalAlignment="Bottom" /> This is loading fine, however everything i have tried to get this image change in code has resulted in nothing being displayed. I tried a MessageBox.Show(TotalFloors.Source.ToS...