How to center or right align the Header in the WPF RadGridView by Telerik?

Telerik is not the best at providing documentation on how to do things, so I figured I would write some of the more mundane tasks that took me a few minutes thought.

Here, I needed to center my headers. It is easy but only if you know all the magic words. If you don’t, it is pretty hard.

Here is how you do it. A simple style.

Snippet

        <telerik:RadTreeListView ItemsSource="{Binding Nodes}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                               IsExpandedBinding="{Binding IsExpanded,Mode=TwoWay}"                                 
                               Name="mainTree"
                               SelectionUnit="FullRow"                                 
                               RowIndicatorVisibility="Collapsed"
                               CanUserResizeColumns="False"
                             SelectedItem="{Binding SelectedNode,Mode=TwoWay}"
                               >
            <telerik:RadTreeListView.Resources>
                <Style BasedOn="{StaticResource {x:Type telerik:GridViewHeaderCell}}" TargetType="{x:Type  telerik:GridViewHeaderCell}">
                    <Setter Property="HorizontalContentAlignment" Value="Center"/>
                </Style>
            </telerik:RadTreeListView.Resources>
......

Happy Coding!

How to run a batch file with administrator priveleges with automatic elevation

Do you have build scripts that require you run commands elevated. Do you forget to click run as admin then you get errors halfway through a 20 minute build?

Well, I did all the damn time. I found this script change and it works awesome so I figured I would share with the class.


if _%1_==_payload_ goto :payload

:getadmin
echo %~nx0: elevating self
set vbs=%temp%\getadmin.vbs
echo Set UAC = CreateObject^(“Shell.Application”^) >> “%vbs%”
echo UAC.ShellExecute “%~s0”, “payload %~sdp0 %*”, “”, “runas”, 1 >> “%vbs%”
“%temp%\getadmin.vbs”
del “%temp%\getadmin.vbs”
goto :eof

:payload
echo %~nx0: running payload with parameters:
echo %*
echo —————————————————
cd /d %2
shift
shift
rem put your code here
rem e.g.: perl myscript.pl %1 %2 %3 %4 %5 %6 %7 %8 %9
rem SEEKFORD – added code for build. I left in above for guys that need params in this blog post.
@cd /d “%~dp0”
set msbuilddir=C:\program Files (x86)\MSBuild\12.0\Bin
“%msbuilddir%\msbuild” “%CD%\SSI.Build” /t:Build /p:Configuration=Debug;ReferencePath=%CD%\..\bin
goto :eof

 

This is a modified version that I got from here (thanks to Alois Mahdal) that adds in how to build using msbuild.

Happy Coding! or emmm.. Happy Building!!