Override default styling in WPF TextBox, based on PresentationFramework.Aero

It seems to work if you put the Style as a lower-level resource, instead of in the same ResourceDictionary: <Grid xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”> <Grid.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source=”/PresentationFramework.Aero, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml”/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Grid.Resources> <Border BorderBrush=”Blue” BorderThickness=”3″> <Border.Resources> <Style TargetType=”{x:Type TextBox}” BasedOn=”{StaticResource {x:Type TextBox}}”> <Setter Property=”Margin” Value=”2″ /> <Setter Property=”Padding” Value=”2″ /> </Style> </Border.Resources> <TextBox … Read more

Why doesn’t Visual Studio want me to add a new window to my WPF project?

Your project is probably configured as a WinForms project, or possibly as a class library. If it’s created as either of these, you are only able to add a WPF UserControl, unfortunately. Of course, there’s no technical reason for this limitation, so you can copy/paste one from another project or recreate/change your project to be … Read more

Using a StaticResource SolidColorBrush to define the Gradient Stop Colors

Ok, I found the problem: Using Color and not SolidColorBrush.. <Color x:Key=”colorbrushMedium”>#FF5A5A5A</Color> <Color x:Key=”colorbrushDark”>#FF222222</Color> <LinearGradientBrush> <GradientStop Color=”{StaticResource colorbrushMedium}”/> <GradientStop Color=”{StaticResource colorbrushDark}” Offset=”1″/> </LinearGradientBrush> This seems to solve my problem!

WPF Canvas, how to add children dynamically with MVVM code behind

ItemsControl is your friend: <Grid> <Image Source=”…”/> <ItemsControl ItemsSource=”{Binding Points}”> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style> <Setter Property=”Canvas.Left” Value=”{Binding X}”/> <Setter Property=”Canvas.Top” Value=”{Binding Y}”/> </Style> </ItemsControl.ItemContainerStyle> <ItemsControl.ItemTemplate> <DataTemplate> <Border BorderBrush=”Red” BorderThickness=”1″ Width=”{Binding Width}” Height=”{Binding Height}”/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </Grid> The above assumes your VM exposes a collection of points via a Points property, and … Read more

Add WPF control at runtime

After you add the your control to the Canvas you need to specify the top and left co-ordinates using the Canvas.Top and Canvas.Left attached properties as follows. var light = new LightUserControl(2); HouseCanvas.Children.Add(light); Canvas.SetLeft(light, 20); Canvas.SetTop(light, 20);

Why is my WPF textbox “kinda” readonly?

I was encountering a problem very similar to this. After doing a little research, I found a similar problem listed in MSDN: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c68d5f3c-c8cc-427d-82e3-6135d075a304/ According to the answer to the post, the problem has to do with WPF and WinForms having two very different ways of handling text input. Fortunately, the post listed above gives the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)