Bring element forward (Z Index) in Silverlight/WPF

I’ve had to deal with this. Say you have an ItemsControl with an ItemTemplate set to an instance of a custom control. Within that control you do Canvas.SetZIndex(this, 99). It won’t work, because “this” is not the immediate child of the ItemsControl’s ItemsPanel. The ItemsControl creates a ContentPresenter for each item, drops that into the … Read more

TextBlock with multiple spacing

if you write all your Runs in the same line, the empty space will go away. Basically a new line here is one empty space on the UI. <TextBlock Foreground=”DarkGray” VerticalAlignment=”Bottom” Margin=”0,0,0,8″><Run Text=”total length “/><Run Text=”{Binding TotalHours}” FontSize=”48″/><Run Text=”h “/><Run Text=”:” FontSize=”48″/><Run Text=”{Binding TotalMinutes}” FontSize=”48″/><Run Text=”m “/></TextBlock>

TemplateBinding to DependencyProperty on a custom control not working

I have encountered this before, TemplateBinding does not work for custom dependency properties on controls. See these related questions: issues with template binding and binding of custom component TemplateBinding does not work in certain cases(when using TranslateTransform) I have always used this instead: {Binding MyProperty, RelativeSource={RelativeSource TemplatedParent}} It is semantically the same as TemplateBinding, and … Read more

How to use Attached property within a style?

Here is how you can set your attached property in a style <Style x:Key=”ToolBarButtonStyle” TargetType=”Button”> <Setter Property=”PrismExt:ImgSourceAttachable.ImgSource” Value=”./Images/New.png”/> <!–…–> </Style> When binding to attached properties then the Path should be within parentheses so try to use RelativeSource Binding with TemplatedParent instead <Setter Property=”Template”> <Setter.Value> <ControlTemplate TargetType=”Button”> <Image x:Name=”toolbarImage” Source=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(PrismExt:ImgSourceAttachable.ImgSource)}” Width=”48″ Height=”48″> </Image> … Read more

What is the difference between Property and Dependency Property

Dependency properties and standard properties are quite different. The key features delivered by dependency properties are support for binding and animation. If you want to assign a value to a property using a Binding or template binding that property needs to be a dependency property. When animating a property the a dependency property can track … Read more

What are these numbers on the right side of my Windows Phone Silverlight app?

That’s the frame rate counter for the emulator / phone that is on by default whenever you debug. To turn it off, go to App.xaml.cs and comment this line out: Application.Current.Host.Settings.EnableFrameRateCounter = true; For more information on what the numbers mean (they can be pretty helpful for tracking app performance), see Jeff Wilcox’s post on … Read more

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