TextBlock does not aligns to right in DataGridTemplateColumn

Hello guys here:
I am currently running into a nasty issue. What I wanna achieve is to put two text blocks horizontally in a DataGridTemplateColumn and I wanna align the right text block text to the right. Here is my code:
<DataGrid ItemsSource="{Binding Path=DVHParameters}"
                                    AutoGenerateColumns="False" 
                                    CanUserResizeColumns="False"
                                    CanUserSortColumns="False"
                                    CanUserReorderColumns="False"
                                    CanUserResizeRows="False"
                                    CanUserAddRows="False"
                                    CanUserDeleteRows="False"
                                    IsHitTestVisible="False"
                                    Visibility="{Binding DVHParametersVisibility}"
                                    Margin="0,0,0,8"
                                    Background="Transparent">
                                <DataGrid.Columns>
                                    <DataGridTemplateColumn Header="                  ">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"
>
                                                    <TextBlock Text="{Binding Parameter}" HorizontalAlignment="Left"/>
                                                    <TextBlock Margin="1,0,0,0" Foreground="Gray" Text="{Binding
ValueUnit}"
                                                        HorizontalAlignment="Stretch" TextAlignment="Right"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTextColumn Header="{x:Static local:TextResources.Prescribed}"
                                        Binding="{Binding Prescribed}"/>
                                    <DataGridTextColumn Header="{x:Static local:TextResources.Actual}" 
                                        Binding="{Binding Actual, StringFormat=F1}">
                                        <DataGridTextColumn.CellStyle>
                                            <Style TargetType="DataGridCell" BasedOn="{StaticResource DataGridCellStyle}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding IsConformObjective}" Value="false">
                                                        <Setter Property="Foreground" Value="Red"/>
                                                        <Setter Property="FontWeight" Value="Bold"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </DataGridTextColumn.CellStyle>
                                    </DataGridTextColumn>
                                </DataGrid.Columns>
                            </DataGrid>
Any hints on how to fix this problem and control the width of the textblock in a DataGridTemplateColumn? Thanks in advance!
Best regards

I suggest you consider dockpanel because I think you can dock one textblock left and one right.
Horzontalalignment stretch tries to stretch it to fit the container, don't use that.
Bear in mind though that you could conceivably end up with one on top of the other if they don't fit.
A grid with 2 columns might be safer.
That'd look roughly like
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<toolkit:DockPanel >
<TextBlock .... toolkit:DockPanel.Dock="Left"/>
<TextBlock .... toolkit:DockPanel.Dock="Right"/>
</StackPanel>
</DataTemplate>
You need a reference and xmlns 
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
or
xmlns:toolkit="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls"
Hope that helps.
Recent Technet articles:
Property List Editing;  
Dynamic XAML

Similar Messages

  • Font just does not align totally left

    Hi folks, I need to know, how i can align the text totally to the border of the text frame, as you can see in the picture it just does not align totally left.
    I´ve been searching the web for solutions but did not find anything. I tried "Textrahmenoptionen" - I guess in english it´s text frame options, but there everything seems so to be right, please help me. Thanks in advance

    Check this thread:
    Re: Text alignment to column (not baseline) guides

  • TS3048 my magic mouse does not want to right click anymore?

    My magic mouse does not seem to right click anymore, any suggestions?  For example, I used to right click on my icon of my memory card from the camera that I have inserted into the side of the IMac and I could choose "eject" now it doesn't want to right click and open up those options.  Am I doing something wrong?

    Hey.
    This seems to be a common issue.
    I've seen mixed posts on the net about the ES8000 working with the Apple Keyboard but from what I've seen the Apple mouse tends to fail the sync constantly.
    Sad, I just bought a mouse to improve navigasting on the ES8000 and dissapointed that it doesn't sync. Maybe an issue with drivers on the TV.
    Which Dell mouse (model number) works for you?

  • Shooting "squeezed" 16:9 does not look quite right when exported to 16:9

    Hard to put a title which would cover the problem well, probably hard to describe it well, too, for an amateur:)
    Anyway, I have a cheap JVC GR-D320E which serves me well as a beginner´s camera (for the price I gave) but when I shoot in what it calls 16:9 mode which I have understood it is not true 16:9 but in a way squeezed, and I import this to FCE (set to Anamorphic PAL), it all looks good within FCE but when I export it using QT Conversions and setting the proportions and size manually to what is supposed to be the right dimensions for 16:9 PAL (1024x576 if I remember it correctly) it does not look right. The persons "grow shorter and fatter", if you know what I mean.
    I have tried to change the dimensions in QT Pro, but the problem is to find the correct ones. I also wonder why this happens and if there actually are "correct" proportions which then would be something between 16:9 and 4:3 or if I am doing something wrong?
    When I export not using QT Conversions, the result is 4:3 which isn´t right, either...
    Well, hope I have been able to describe this in a way which is possible to understand...

    I want to export it for several purposes; all you mention, in fact; to put on the web, to play on the monitor and to make a DVD. As I mentioned, when I exported as a QuickTime movie, it came out as a 4:3 and that of course, looked awful.
    Using the conversions, I can scale it as I want to, but to me 16:9 does not look exactly right, either. That is why I wanted to know if there are some proportions in between the 4:3 and 16:9 which is appropriate for footage which is not filmed in true 16:9 but in this option which cheaper cameras have.
    The article you linked to, did not tell anything new, alas.

  • Graph Data does not align with the axis label

    Hi,
    The graph data does not align with the axis label when
    datetimeaxis is used.
    http://livedocs.adobe.com/labs/flex3/html/help.html?content=charts_displayingdata_04.html
    (in the using parseFunction property example) when you hover on the
    line graph the values do not align on the labels. Is this a bug?
    Can somebody help me with this.
    Thank you,
    Gautam.

    Hi All
    Thanks for looking into it.
    Actually we have just added a field GJAHR (was missing in the extractor) so that it takes data accoring to fiscal yr. Actually we had a issue that the Business area for a particular vendor 'X' and doc no 'Y' was showing incorrectly (similar to that of yr 2008) but it changed this yr and the extractor was still picking Business Area for yr 2008.
    So we added GJAHR field so that it takes correct Business Area. we have checked in R/3 Extractor checker and it shows correctly.
    But that change has not reflected in BW yet even after replicating datasource.
    I hope i have made you all understand the situation.
    Thanks for your help
    Ishi

  • HT201401 What you sent me does not help me right My problem is the hardware of the iPhone and its settings I have a problem I Cmtor Home is not where his curve and let's make noise and not working

    Hello my name is and I'm from Israel Lidor My home button on the iPhone 5 does not pass he makes heads and crooked, I bought it from Apple in Spain Barcelona If you can do something with this issue Nora will thank you.!
    What you sent me does not help me right
    My problem is the hardware of the iPhone and its settings
    I have a problem I Cmtor Home is not where his curve and let's make noise and not working

    The warranty is NOT international. The exception is the E.U.
    Since Spain is an E.U. Member country, you can take it back to an Apple Store in any EU country for service. It can not be serviced outside of the E.U.

  • Week No. on new P45 forms does not align and prints outside the ...

    The new P45 sapscript (HR_GB_P45_A4_D & HR_GB_P45_A4) does not align the Week number within the box of the pre-printed HMRC stationery. The week number appears on all three forms (1/1A, 2 and 3), being page 1,2 and 3 of the sapscript, and all are printed out of their appropriate box.
    Has anyone else encountered this problem ?.
    I can correct this as we currently use a Z version of the sapscript. I have checked the Z version (a recent copy) of the SAP original sapscript to ensure that the original will also have a mis-alignment, which it does. However, despite changing this I would still like SAP to correct their mistakes. I must admit I am VERY surprised that nobody else has encountered this problem as any week number being displayed on either the HR_GB_P45_A4 or HR_GB_P45_A4_D form will not align correctly.
    Jason
    Edited by: Jason Stratham on May 26, 2009 2:55 PM
    Edited by: Jason Stratham on May 26, 2009 4:28 PM

    P45 form printing to tray 1,2, and 3.
    On a slightly related subject we occassionally find that our lexmark three bin printer seems to forget it's bin setup and every now and then the pages will come out on the wrong HMRC pre-printer stationey. We have double-checked the paper loaded and we ONLY have the P45 form 1/1A in try 1, form 2 in tray 2 and form 3 in tray 3. However, despite this it still occassionally goes wrong, with the form 1 and 2 printing to tray 2 and form 3 printing to tray 3. This normally happens after a long weekend, so I don't know whether this is a printer driver caching problem or suchlike. Has anyone had any similar problems?.
    Jason

  • This log in user does not have proper rights to use WebCenter Capture

    Hi experts,
    We have WCI 11.1.1.8.0 setup. It has WEC configured. However when I login with "weblogic" user. This is domain admin user. WEC allows user to login and shows top navigation bar. However in the body it shows below message
    "This log in user does not have proper rights to use WebCenter Capture"
    I am sure i have not gives a proper group/ role to this user. I am not sure which one is that.
    Regards,
    Vikrant Korde.

    Hi Vikrant,
    This happens if user is not in Capture Application Role.
    Check this:
    Log in to EM
    Right-click the capture_domain, select Security, and then Application Roles
    In the Application Stripe field, select capture, and then click the Search application roles icon to display the Capture application roles.
    In the Capture User add this weblogic.
    It will work now.

  • TA48312 Hello I have a Mac Mini with OS 10.7.5 And I have a problem that the mouse does not do a right mouse ... I have the mouse model a1197 What should I do? Thank you

    Hello I have a Mac Mini with OS 10.7.5 And I have a problem that the mouse does not do a right mouse ... I have the mouse model a1197 What should I do? Thank you

    Why is there no iDVD on my new Mac? How do I get it and how do I install it?
    https://discussions.apple.com/docs/DOC-3673

  • Weblogic 10.3.2.0 installation does not pick the right JDK

    The installation does not pick up the right jdk version that is jdk 11.6.0_11 . Although the machine is running the same. Instead it picks up jdk 1.6.0_14. have tested the machine many times. I am Installing Oracle SOA Suite 11g.

    Inside "startWebLogic.sh" file add the JAVA_HOME like following (just below the "setDomainEnv.sh" call):
    JAVA_HOME=C:\bea103\jdk1.6.0_17
    See if this helps.
    Thanks

  • How do I "Save target as ..." when it does not exist on right clicking in Firefox?

    Some web sites allow files and free mp3 tracks to be downloaded by right clicking on an icon and selecting "save target as ...". But Firefox does not have this option. How do others handle this? I have had to go back to Internet Explorer to use this privilege.
    == This happened ==
    Every time Firefox opened
    == Always been so for me.

    no it isn't........this option saves as an HTML document link. it does not download the file.

  • Hp color laserjet cp1518ni color does not align???

    I recently posted at the beginning of the month saying I was having problems with my hp color laserjet cp1518ni and the whole left side printing blurry.  After cleaning the rollers, running it through the cleaning mode, restoring the defaults and calibrating the colors, it miraculously worked.   
    But less than a month into the fix and I am once again having problems.  I have done all of the following (I have windows vista 64bit):
    *updated firmware and confirmed that it is updated to most current version 20120110
    *restarted computer
    *turned off printer - more than once
    *disconnected printer - more than once
    *restored defaults - more than once
    *calibrated color - more than once
    *run it through the cleaning mode - more than once
    I have taken each toner cartridge out and carefully placed them back in again making sure they were firmly in place.
    My husband has tried connecting it to his computer and printing it, but has gotten the same results. 
    I was trying to print out a job when I noticed that the color was horribly off from what was on my computer screen.  Since I was 5 prints away from needing to change the cyan cartridge, I changed it, thinking this would fix the color.  Not only did it not fix the color, but that's when the alignment problems started happening.  I am so completely frustrated.  It is ridiculous to have this kind of problems with a printer every time you try to print and I've spent the last 3 hours fighting with it.
    I am absolutely, without a doubt, certain it is the printer.  I don't know what it is, with the printer, so if anyone has any advice, I would greatly appreciate it.  I just opened a 3 pack of toner (to put the cyan in) so now not only can I not use the printer, but I am out money for the other 2 toners.
    The reason I know it is the printer, is because I finally I printed the same exact piece I had been printing on the hp color laserjet cp1518ni that looked horrible in both color and color alignment, onto a Canon MG6120 inkjet.  The color was exactly as it appeared on my computer screen and there were no problems with misalignment.  I just prefer to do my jobs on laserjet printing, so this is frustrating to have a large, expensive doorstop in my computer room.
    Any help is much appreciated.

    I wanted to add one more thing, as I was looking through the Resolving Print Quality Issues page
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c01691481&tmp_task=solveCategory&cc=us&dlc=en&lc​...
    I have printed out a Diagnostics Report and it's obvious that there is a problem. Under Solution #11, it tells you how to
    Identify and replace the problem print cartridge
    Because it allows you to print and see:
    The page prints five bands of color, which are divided into four overlapping sections. By examining each section, you can isolate the problem to a particular print cartridge.
    I have done a search on my computer for:
    HP Color LaserJet CP1510 Series ToolboxFX and it does not come up. I am able to do everything through the printer itself (run the cleaning mode, etc), but as far as finding anything on my computer under a folder, there doesn't appear to be anything.
    I'd like to be able to print out these pages so that I can see which colors are giving me problems. Is there a way to do that from the printer?
    Thank you!

  • My computer does not start up right away after I close the top... Is my hard drive going bad? Help please!

    I typically just close my computer when I'm done with it, instead of putting it to sleep or logging off. Recently, when I open it back up, it does not start right away. I have to press the power button half a dozen times before it starts. HELP!!

    annie1977-
    Greetings and welcome.
    Try booting from the system install CD/DVD by putting the disk in the drive and starting up while holding down the c key.
    After boot-up find the Disk Utility, either on the desktop or under the Apple menu. Select your startup drive and the repair permissions on that drive. See if that helps.
    Luck-
    -DaddyPaycheck

  • Avery Barcode labels does not align properly when printed from Adobe Reader 11.0.0

    Hi,
    I have barcode labels in a PDF (Version 1.4, Acrobat 5.x). PDF producer is PPAlambic(Distiller). When I try to print the PDF on to Avery 5160 sheet containing 30 labels (10 rows; 3 labels in a row), always the barcodes on the first column goes beyond the left margins and hence does not print the full barcode. PDF size is 8.5" * 11" .I have tried following options in Print dialog box:
    1. Actual Size + Portrait + Letter size
    2. Shrink oversized pages + Portrait + Letter size
    3. Fit + Portrait + Letter size
    None of the above options resolved my issue.
    When I open the same PDF in Adobe Reader 11.0.07, it prints perfectly. Does someone help me understand if this is a known defect in Adobe 11.0.0 and is there any workaround in 11.0.0 itself to adjust the alignment?
    Note: PDF is not editable as it comes from a third party vendor. Please help.

    Hi,
    I have barcode labels in a PDF (Version 1.4, Acrobat 5.x). PDF producer is PPAlambic(Distiller). When I try to print the PDF on to Avery 5160 sheet containing 30 labels (10 rows; 3 labels in a row), always the barcodes on the first column goes beyond the left margins and hence does not print the full barcode. PDF size is 8.5" * 11" .I have tried following options in Print dialog box:
    1. Actual Size + Portrait + Letter size
    2. Shrink oversized pages + Portrait + Letter size
    3. Fit + Portrait + Letter size
    None of the above options resolved my issue.
    When I open the same PDF in Adobe Reader 11.0.07, it prints perfectly. Does someone help me understand if this is a known defect in Adobe 11.0.0 and is there any workaround in 11.0.0 itself to adjust the alignment?
    Note: PDF is not editable as it comes from a third party vendor. Please help.

  • Reader 9.2 does not choose the right postscript level

    Hi,
    I use an old HP4500 Color Laser Jet (it still prints very well and I have a lot of toner :-)). every time I want to print a pdf on it, it does not work, for the adobe reader sets the postscript level to 3 although the printer has only 2.
    I've found the information anywhere in the adobe pages, which say:
    "Note: Acrobat sets the PostScript level automatically, based on the selected printer."
    In my printer settings (Win7-64 bit, driver: HP Universal Printing PS Version 12.4.2009, 61.94.3.37) I have set the level to 2 (Dokumentoptions:Postscript Options:Postscript language level: 2)
    But Adobe Reader is not interested in my settings and sets it to 3 every time and I have to change it manually every time. That is not funny, when printing many pdfs.... :-(((
    I don't understand this, it has happend with another driver under windows xp the same way, but now I have lost my patience.
    Why does the reader does not work properly or can I tell him to do so ?
    Best regards
    Thomas keller, Germany

    Thanks Bernd!  Works just fine now. Am I that obtuse that I wasn't able to
    figure this out on my own?

Maybe you are looking for

  • K8N diamond - memory upgrade advice?

    Hi all, I would like to ask local experts for quick advise on memory upgrade. Originally I though that this is easy task but via reading some of discussions here it doesn't seems so easy anymore.... What I have: Board: K8N Diamond BIOS version: 1.A0

  • ABAP Report Writer

    Dear All Can some one help me to have a good document / manual for ABAP - Report Writer.  Regards, Venkat Moderator Message: Please do not ask for documentation here. Instead, Search for them. Edited by: kishan P on Oct 19, 2010 10:04 AM

  • Banner Ad problem in flash

    Hi All I would like help with an error happen when I want to modifiy a banner ad made in flash mx 2004. He wsnt keep the same fonts and special effect. See below the two links. Here is my original banner ad in FLASH MX 2004 I would like the same resu

  • Change the memory used by de NWDS

    Hi masters. Please, how can I change de minimal and maximal memory that NWDS take to itself ? My NWDS needs to became more faster.

  • Cs4 tabs too hard to see

    hi I really hate the apple style black text on dark grey tabs. It just doesn't provide enough contrast for my poor eyes. Is there a way to change this? thanks