wpf

Best way to create/edit a template programatically

I could use FrameworkElementFactory to create a template, but this class is deprecated. The recommended way, according to MSDN is to use XamlReader.Load to load XAML from a string or a memory stream. I get this to work, but think this is kind of sad: string xaml = "a lot of XAML"; Any suggestions to be able to do this in a better way?...

Is it a good idea to aggregate ViewModels in WPF

Is it a good\bad idea to have a ViewModel as property of another ViewModel? eg. public sealed class ContentManagerViewModel : ViewModel { public FindViewModel Find { get; set; } } Cheers AWC ...

I need a little bit of help with my logic here. How can I have a picture select change image on Click?

Here's what I have: private void HeroMouseEnter(object sender, MouseEventArgs e) { //I did things this was because it is easier to maintain code in a sense that is is a generic //method made for all of the heroes images. ((Image)sender).Source = GetGlowingImage(((Image)sender).Name); ...

WPF WebBrowser Silent mode through IWebBrowser2 interface not working?

I'm trying to silence Javascript errors in the WPF webbrowser control. According to the "Getting to the native IWebBrowser2" comment on this page, one can access the IWebBrowser2 interface. From there I thought I could set the Silent property to true, like this: /// <summary> /// Handle navigation events /// </summary> p...

WPF/Silverlight: Instantly render large amounts of multi-colored text

I need to constantly display large amounts of colored text in WPF or Silverlight, and I need the user to percieve it as showing up instantly. Currently I'm doing this using a canvas and textblocks, one textblock per 80-character line, with multiple runs to a textblock to handle the different colors. There can often be 20+ runs to a lin...

Office 2010 Look and Feel?

I am getting started on a WPF app whose UI will be modeled rather loosely on Outlook. I would like to emulate the Blue color scheme in the Outlook 2010 beta. Has anyone seen any tutorials or recipes that describe how to style WPF buttons so that they look like Outlook 2010's Task buttons? Those are the ones in the lower-left corner of th...

WPF Textbox Border

I have a textbox that I want to validate, but when I validate it and whatever way I am setting the border seems to actually wrap the actual border I want to change inside the textbox i.e. it adds another border outside the textbox. Has anyone got any example of how to set a pixel perfect border that doesn't look pants on an event? ...

Copying a file from an IsolatedStorage

Hi, I was just wondering if there is a way to prevent people from copying a file which is stored by using System.IO.IsolatedStorage? To me, I can't think of anyway. Any person can go and grab those files manually. Is there other ways that I am missing? ...

Visual Studio 2008 WPF Project error "project type is not supported"

I'm running Windows 7 x64 with Visual Studio 2008 (SP1). Yesterday I came across an issue when creating WPF projects. I don't know if I've created any other WPF projects since I installed Win7. First of all, in the Create Project dialog, the project type says "csWPFApplication" which is weird enough and I never noticed before. When I...

Silverlight 3 TextBlock leaves blank space above text

I have the following in my XAML: <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="20"/> <RowDefinition Height="7"/> <RowDefinition Height="57"/> </Grid.RowDefinitions> <TextBlock Grid.Row="0" FontSize="18">Title Text</TextBlock> <Rectangle Grid.Row="1" M...

WPF - Random hanging with file browser attached behaviour.

Hi, I have an attached behavior defined thusly,.. public static class FileBrowserBehaviour { public static bool GetBrowsesOnClick(DependencyObject obj) { return (bool)obj.GetValue(BrowsesOnClickProperty); } public static void SetBrowsesOnClick(DependencyObject obj, bool value) { obj.SetValue(BrowsesOnClickProperty, valu...

Change Page in Frame Control

I've got a Page in a Frame Control. I want to change it by clicking button in a current page. How can I do it? I've got a full-screen desktop application on WPF (without any window's title and system buttons). ...

How do I navigate a table using the entity framework?

I'm trying to create a simple table navigation screen in WPF using the entity framework on a database with one table, Students. The screen basically has the the students name and surname and back and forwards button. The datacontext is pointing directly to the Students table and is setup as follows: private DBEntities _entity = new DBE...

Using x:Name or Name in WPF

My understanding of x:Name vs Name is that some controls have a Name property, that is basically the same as setting x:Name. Is there an advantage to using Name when it is available over x:Name? Here's my reference for understanding x:Name vs Name. ...

Composite WPF Problem -- View and Presenter Constructors Don't Run

Hello All, Please consider the VS 2008 .NET 3.5 SP 1 solution at this location: http://www.theese.com/SolutionName.zip This application uses Microsoft's Composite WPF (aka Prism) architecture. It is a very simple app that demonstrates a problem I'm having. I have one module with one view. That view gets mapped to the one and only regi...

WPF TreeView with IsVirtualizing="true" jumps around when changing focus and scrolling

I've made a simple example to reproduce a problem I'm having with the TreeView. If I select an item in the TreeView, scroll down, change the focus, and then select an item in the TreeView again, the list starts jumping around. This only happens if I have VirtualizingStackPanel.IsVirtualizing="True". Is this a known problem? Is there ...

Win7 WPF Alt+Tab Focus Oddity

After a couple hours of Googling I haven't been able to find any comments on this issue. We have a WindowStyle=None window with transparent background and allows transparency and does not show in taskbar, all pretty normal. Here's the XAML so you can test for yourself: <Window x:Class="AltTabTest.Window1" xmlns="http://schemas.microsoft...

Basic WPF databinding question

I have another WPF databinding question... one that I haven't found an answer to anywhere, and this surprises me since it seems like it is very basic. Essentially, I have a string in code behind that I would like to establish a two-way binding with with a textbox in my GUI. I thought it was a simple matter of creating a DependencyPrope...

Rendering a non UIElement via binding

If I have an object derived from System.Windows.DispatcherObject but defines a ControlTemplate. public class A : System.Windows.DependencyObject { public ControlTemplate ControlTemplate {get; set;} } which is a member of public class B { public A NonUIElement {get; set;} } Is it possible to render this object via a Binding...

styling generic WPF controls

I am looking into creating type-safe generic controls. This is targeting the (reduced) generics support in WPF 4 and future Silverlight, and will include a hierarchy of generic controls. I have two questions: Can you use style setters and template bindings for non-generic properties defined on a generic control? In Silverlight, is the...