Difference between Label and TextBlock

TextBlock is not a control Even though TextBlock lives in the System.Windows.Controls namespace, it is not a control. It derives directly from FrameworkElement. Label, on the other hand, derives from ContentControl. This means that Label can: Be given a custom control template (via the Template property). Display data other than just a string (via the … Read more

How to bind multiple values to a single WPF TextBlock?

You can use a MultiBinding combined with the StringFormat property. Usage would resemble the following: <TextBlock> <TextBlock.Text> <MultiBinding StringFormat=”{}{0} + {1}”> <Binding Path=”Name” /> <Binding Path=”ID” /> </MultiBinding> </TextBlock.Text> </TextBlock> Giving Name a value of Foo and ID a value of 1, your output in the TextBlock would then be Foo + 1. Note: This … Read more

Text vertical alignment in WPF TextBlock

A Textblock itself can’t do vertical alignment The best way to do this that I’ve found is to put the textblock inside a border, so the border does the alignment for you. <Border BorderBrush=”{x:Null}” Height=”50″> <TextBlock TextWrapping=”Wrap” Text=”Some Text” VerticalAlignment=”Center”/> </Border> Note: This is functionally equivalent to using a grid, it just depends how you … Read more

Automatic vertical scroll bar in WPF TextBlock?

Wrap it in a scroll viewer: <ScrollViewer> <TextBlock /> </ScrollViewer> NOTE this answer applies to a TextBlock (a read-only text element) as asked for in the original question. If you want to show scroll bars in a TextBox (an editable text element) then use the ScrollViewer attached properties: <TextBox ScrollViewer.HorizontalScrollBarVisibility=”Disabled” ScrollViewer.VerticalScrollBarVisibility=”Auto” /> Valid values for … Read more

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