Search Results

Search found 60 results on 3 pages for 'stringformat'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Wpf Resource: "Unknown Build Error, 'Path cannot be null..."

    - by Femaref
    The following is a snippet from a xaml defining a DataGrid in a Control, defining a template selector. <DataGrid.Resources> <selector:CurrencyColorSelector x:Key="currencyColorSelector"> <selector:CurrencyColorSelector.NegativeTemplate> <DataTemplate> <TextBlock Text="{Binding Balance, StringFormat=n}" Background="Red"/> </DataTemplate> </selector:CurrencyColorSelector.NegativeTemplate> <selector:CurrencyColorSelector.NormalTemplate> <DataTemplate> <TextBlock Text="{Binding Balance, StringFormat=n}"/> </DataTemplate> </selector:CurrencyColorSelector.NormalTemplate> </selector:CurrencyColorSelector> </DataGrid.Resources> Now, an error is thrown: "Unknown build error, 'Path cannot be null. Parameter name: path Line 27 Position 79.'" (Compiler or xaml validation error). I have no idea where this Path comes from, neither does my example show anything of it. If you doubleclick the error, it points to the end of the first line. Did anybody encounter such a problem and has a solution for it? The example was from here: http://www.wpftutorial.net/DataGrid.html (Row Details depending on the type of data)

    Read the article

  • Dealing with SerializationExceptions in C#

    - by Tony
    I get a SerializationException: (...) is not marked as serializable. error in the following code: [Serializable] public class Wind { public MyText text; public Size MSize; public Point MLocation; public int MNumber; /.../ } [Serializable] public class MyText { public string MString; public Font MFont; public StringFormat StrFormat; public float MySize; public Color FColor, SColor, TColor; public bool IsRequest; public decimal MWide; /.../ } and the List to be serialized: List<Wind> MyList = new List<Wind>(); Code Snippet: FileStream FS = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "Sticks.dat", FileMode.Create); BinaryFormatter BF = new BinaryFormatter(); BF.Serialize(FS, MyList); FS.Close(); throws an Exception: System.Runtime.Serialization.SerializationException was unhandled Message="Type 'System.Drawing.StringFormat' in Assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." How do I solve this problem?

    Read the article

  • How does FallbackValue work with a MultiBiding?

    - by Will
    I ask because it doesn't seem to work. Assume we're binding to the following object: public class HurrDurr { public string Hurr {get{return null;}} public string Durr {get{return null;}} } Well, it would appear that if we used a MultiBinding against this the fallback value would be shown, right? <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} to the {1}" FallbackValue="Not set! It works as expected!)"> <Binding Path="Hurr"/> <Binding Path="Durr"/> </MultiBinding> </TextBlock.Text> </TextBlock> However the result is, in fact, " to the ". Even forcing the bindings to return DependencyProperty.UnsetValue doesn't work: <TextBlock xmnlns:base="clr-namespace:System.Windows;assembly=WindowsBase"> <TextBlock.Text> <MultiBinding StringFormat="{}{0} to the {1}" FallbackValue="Not set! It works as expected!)"> <Binding Path="Hurr" FallbackValue="{x:Static base:DependencyProperty.UnsetValue}" /> <Binding Path="Durr" FallbackValue="{x:Static base:DependencyProperty.UnsetValue}" /> </MultiBinding> </TextBlock.Text> </TextBlock> Tried the same with TargetNullValue, which was also a bust all the way around. So it appears that MultiBinding will never ever use FallbackValue. Is this true, or am I missing something?

    Read the article

  • C# : changing listbox row color?

    - by Meko
    HI. I am trying to changing backround colorof some rows on listbox.I have 2 list that one has all names and it shown on listbox.And second list has some same value with first list.I want to show that when clicking button it will search in listbox and in second list then will change color where found value. I may search in list box like for (int i = 0; i < listBox1.Items.Count; i++) { for (int j = 0; j < students.Count; j++) if (listBox1.Items[i].ToString().Contains(students[j].ToString())) { } } But I don't know which method to change appearances of row.Any help? *EDIT: * HI I made my code like private void ListBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); Graphics g = e.Graphics; Brush myBrush = Brushes.Black; Brush myBrush2 = Brushes.Red; g.FillRectangle(new SolidBrush(Color.Silver), e.Bounds); e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault); for (int i = 0; i < listBox1.Items.Count; i++) { for (int j = 0; j < existingStudents.Count; j++) if (listBox1.Items[i].ToString().Contains(existingStudents[j])) { e.Graphics.DrawString(listBox1.Items[i].ToString(), e.Font, myBrush2, e.Bounds, StringFormat.GenericDefault); } } e.DrawFocusRectangle(); } Now it draws my list on listbox.But when I click button first it shows only student that in list with red color but when I click on listbox it again draws all elements.I want that it will show all element ,when I click button it will show all elements and founded element in list with red color.Whre is my mistake?

    Read the article

  • DataGrid calculate difference between values in two databound cells

    - by justMe
    Hello! In my small application I have a DataGrid (see screenshot) that's bound to a list of Measurement objects. A Measurement is just a data container with two properties: Date and CounterGas (float). Each Measurement object represents my gas consumption at a specific date. The list of measurements is bound to the DataGrid as follows: <DataGrid ItemsSource="{Binding Path=Measurements}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="Date" Binding="{Binding Path=Date, StringFormat={}{0:dd.MM.yyyy}}" /> <DataGridTextColumn Header="Counter Gas" Binding="{Binding Path=ValueGas, StringFormat={}{0:F3}}" /> </DataGrid.Columns> </DataGrid> Well, and now my question :) I'd like to have another column right next to the column "Counter Gas" which shows the difference between the actual counter value and the last counter value. E.g. this additional column should calculate the difference between the value of of Feb. 13th and Feb. 6th = 199.789 - 187.115 = 15.674 What is the best way to achieve this? I'd like to avoid any calculation in the Measurement class which should just hold the data. I'd rather more like the DataGrid to handle the calculation. So is there a way to add another column that just calculates the difference between to values? Maybe using some kind of converter and extreme binding? ;D P.S.: Maybe someone with a better reputation could embed the screenshot. Thanks :)

    Read the article

  • String Formatting with concatenation or substitution

    - by Davio
    This is a question about preferences. Assume a programming language offers these two options to make a string with some variables: "Hello, my name is ". name ." and I'm ". age ." years old." StringFormat("Hello, my name is $0 and I'm $1 years old.", name, age) Which do you prefer and why? I have found myself using both without any clear reason to pick either. Considering micro-optimizations is not within the scope of this question. Localization has been mentioned as a reason to go with option #2 and I think it's a very valid reason and deserves to be mentioned here. However, would opinions differ based on aesthetic viewpoints?

    Read the article

  • Current Date in Silverlight XAML TextBlock

    - by user292110
    I am coming from Flex where you can do just about anything inside of curly braces. I am trying to get a TextBlock to display today's Date and Time without just coding it in C#. I have tried many different variations of the following with no luck. TextBlock Text="{Source=Date, Path=Now, StringFormat='dd/MM/yyyy'}" I know I could probably just set a property MyDate and bind to that but why can't I bind directly to the DateTime.Now property?

    Read the article

  • Generic styles for DataGridTemplateColumn Headers & Cells

    - by user557765
    I am struggling to define templates for my DataGrid columns. Here is the code that I have working at the moment: <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" > <t:DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldNameVertical}" Text="Date" /> </DataTemplate> </t:DataGridTemplateColumn.HeaderTemplate> <t:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" /> </DataTemplate> </t:DataGridTemplateColumn.CellTemplate> </t:DataGridTemplateColumn> .. .. .. </t:DataGrid.Columns> I would like to define HeaderTemplate & CellTemplate as reusable styles -- so that each column would be as brief as something like this: <t:DataGrid.Resources> <DataTemplate x:Key="dgHeaderStyle"> <TextBlock Style="{StaticResource FieldNameVertical}" Text="{Binding}" /> </DataTemplate> <DataTemplate x:Key="dgCellStyle"> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding}" /> </DataTemplate> </t:DataGrid.Resources> <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" Header="Date" Binding="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> <t:DataGridTemplateColumn Width="100" Header="Dealer" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> ... </t:DataGrid.Columns> Every attempt I make has failed. I had hoped to implement something like the "solution" snippet in the initial entry of WPF DataGrid HeaderTemplate Mysterious Padding. However, I can't seem to adapt it to what I'm doing.

    Read the article

  • My ashx stopped working (Works locally, but not online)

    - by Madi D.
    i have a simple ASHX file that returns pictures upon request (mainly a counter), previously the code simply fetched pre-made pictures(already uploaded and available) and sent them to the requester.. i just modified the code,so it would take a base picture, do some modifications on it, save it to the server, then serve it to the user.. tested it locally and it worked like a charm. however when i uploaded the code to my hosting service (Godaddy..) it didnt work. Can someone point the problem out to me? Note: ASHX worked with me before,so i know the web.config and IIS are handling them properly, however i think i am missing something .. Code: <%@ WebHandler Language="C#" Class="NWEmpPhotoHandler" %> using System; using System.Web; using System.IO; using System.Drawing; using System.Drawing.Imaging; public class NWEmpPhotoHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext ctx) { try { //Some Code to fetch # of vistors from DB int x = 10,000; // # of Vistors, fetched from DB string numberOfVistors = (1000 + x).ToString(); string filePath = ctx.Server.MapPath("counter.jpg"); Bitmap myBitmap = new Bitmap(filePath); Graphics g = Graphics.FromImage(myBitmap); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; StringFormat strFormat = new StringFormat(); g.DrawString(numberOfVistors , new Font("Tahoma", 24), Brushes.Maroon, new RectangleF(55, 82, 500, 500),null); string PathToSave = ctx.Server.MapPath("counter-" + numberOfVistors + ".jpg"); saveJpeg(PathToSave, myBitmap, 100); if (File.Exists(PathToSave)) { ctx.Response.ContentType = "image/jpg"; ctx.Response.WriteFile(PathToSave); //ctx.Response.OutputStream.Write(picByteArray, 0, picByteArray.Length); } } catch (ArgumentException exe) { } } private ImageCodecInfo getEncoderInfo(string mimeType) { // Get image codecs for all image formats ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); // Find the correct image codec for (int i = 0; i < codecs.Length; i++) if (codecs[i].MimeType == mimeType) return codecs[i]; return null; } private void saveJpeg(string path, Bitmap img, long quality) { // Encoder parameter for image quality EncoderParameter qualityParam = new EncoderParameter(Encoder.Quality, quality); // Jpeg image codec ImageCodecInfo jpegCodec = this.getEncoderInfo("image/jpeg"); if (jpegCodec == null) return; EncoderParameters encoderParams = new EncoderParameters(1); encoderParams.Param[0] = qualityParam; img.Save(path, jpegCodec, encoderParams); } }

    Read the article

  • class hierarchy design for small java project

    - by user523956
    I have written a java code which does following:- Main goal is to fetch emails from (inbox, spam) folders and store them in database. It fetches emails from gmail,gmx,web.de,yahoo and Hotmail. Following attributes are stored in mysql database. Slno, messagedigest, messageid, foldername, dateandtime, receiver, sender, subject, cc, size and emlfile. For gmail,gmy and web.de, I have used javamail API, because email form it can be fetched with IMAP. For yahoo and hotmail, I have used html parser and httpclient to fetch emails form spam folder and for inbox folder, I have used pop3 javamail API. I want to have proper class hierarchy which makes my code efficient and easily reusable. As of now I have designed class hierarchy as below: I am sure it can still be improved. So I would like to have different opinions on it. I have following classes and methods as of now. MainController:- Here I pass emailid, password and foldername from which emails have to be fetched. Abstract Class :-EmailProtocol Abstract Methods of it (All methods except executeParser contains method definition):- connectImap() // used by gmx,gmail and web.de email ids connectPop3() // used by hotmail and yahoo to fetch emails of inbox folder createMessageDigest // used by every email provider(gmx, gmail,web.de,yahoo,hotmail) establishDBConnection // used by every email emailAlreadyExists // used by every email which checks whether email already exists in db or not, if not then store it. storeemailproperties // used by every email to store emails properties to mysql database executeParser // nothing written in it. Overwridden and used by just hotmail and yahoo to fetch emails form spam folder. Imap extends EmailProtocol (nothing in it. But I have to have it to access methods of EmailProtocol. This is used to fetch emails from gmail,gmx and web.de) I know this is really a bad way but don't know how to do it other way. Hotmsil extends EmailProtocol Methods:- executeParser() :- This is used by just hotmail email id. fetchjunkemails() :- This is also very specific for only hotmail email id. Yahoo extends EmailProtocol Methods:- executeParser() storeEmailtotemptable() MoveEmailtoInbox() getFoldername() nullorEquals() All above methods are specific for yahoo email id. public DateTimeFormat(class) format() //this formats datetime of gmax,gmail and web.de emails. formatYahoodate //this formats datetime of yahoo email. formatHotmaildate // this formats datetime of hotmail email. public StringFormat ConvertStreamToString() // Accessed by every class except DateTimeFormat class. formatFromTo() // Accessed by every class except DateTimeFormat class. public Class CheckDatabaseExistance public static void checkForDatabaseTablesAvailability() (This method checks at the beginnning whether database and required tables exist in mysql or not. if not it creates them) Please see code of my MainController class so that You can have an idea about how I use different classes. public class MainController { public static void main(String[] args) throws Exception { ArrayList<String> web_de_folders = new ArrayList<String>(); web_de_folders.add("INBOX"); web_de_folders.add("Unbekannt"); web_de_folders.add("Spam"); web_de_folders.add("OUTBOX"); web_de_folders.add("SENT"); web_de_folders.add("DRAFTS"); web_de_folders.add("TRASH"); web_de_folders.add("Trash"); ArrayList<String> gmx_folders = new ArrayList<String>(); gmx_folders.add("INBOX"); gmx_folders.add("Archiv"); gmx_folders.add("Entwürfe"); gmx_folders.add("Gelöscht"); gmx_folders.add("Gesendet"); gmx_folders.add("Spamverdacht"); gmx_folders.add("Trash"); ArrayList<String> gmail_folders = new ArrayList<String>(); gmail_folders.add("Inbox"); gmail_folders.add("[Google Mail]/Spam"); gmail_folders.add("[Google Mail]/Trash"); gmail_folders.add("[Google Mail]/Sent Mail"); ArrayList<String> pop3_folders = new ArrayList<String>(); pop3_folders.add("INBOX"); CheckDatabaseExistance.checkForDatabaseTablesAvailability(); EmailProtocol imap = new Imap(); System.out.println("CHECKING FOR NEW EMAILS IN WEB.DE...(IMAP)"); System.out.println("*********************************************************************************"); imap.connectImap("[email protected]", "pwd", web_de_folders); System.out.println("\nCHECKING FOR NEW EMAILS IN GMX.DE...(IMAP)"); System.out.println("*********************************************************************************"); imap.connectImap("[email protected]", "pwd", gmx_folders); System.out.println("\nCHECKING FOR NEW EMAILS IN GMAIL...(IMAP)"); System.out.println("*********************************************************************************"); imap.connectImap("[email protected]", "pwd", gmail_folders); EmailProtocol yahoo = new Yahoo(); Yahoo y=new Yahoo(); System.out.println("\nEXECUTING YAHOO PARSER"); System.out.println("*********************************************************************************"); y.executeParser("http://de.mc1321.mail.yahoo.com/mc/welcome?ymv=0","[email protected]","pwd"); System.out.println("\nCHECKING FOR NEW EMAILS IN INBOX OF YAHOO (POP3)"); System.out.println("*********************************************************************************"); yahoo.connectPop3("[email protected]","pwd",pop3_folders); System.out.println("\nCHECKING FOR NEW EMAILS IN INBOX OF HOTMAIL (POP3)"); System.out.println("*********************************************************************************"); yahoo.connectPop3("[email protected]","pwd",pop3_folders); EmailProtocol hotmail = new Hotmail(); Hotmail h=new Hotmail(); System.out.println("\nEXECUTING HOTMAIL PARSER"); System.out.println("*********************************************************************************"); h.executeParser("https://login.live.com/ppsecure/post.srf","[email protected]","pwd"); } } I have kept DatetimeFormat and StringFormat class public so that I can access its public methods by just (DatetimeFormat.formatYahoodate for e.g. from different methods). This is the first time I have developed something in java. It serves its purpose but of course code is still not so efficient I think. I need your suggestions on this project.

    Read the article

  • Why is my WCF RIA Services custom object deserializing with an extra list member?

    - by oasasaurus
    I have been developing a Silverlight WCF RIA Services application dealing with mock financial transactions. To more efficiently send summary data to the client without going overboard with serialized entities I have created a summary class that isn’t in my EDM, and figured out how to serialize and send it over the wire to the SL client using DataContract() and DataMember(). Everything seemed to be working out great, until I tried to bind controls to a list inside my custom object. The list seems to always get deserialized with an extra, almost empty entity in it that I don’t know how to get rid of. So, here are some of the pieces. First the relevant bits from the custom object class: <DataContract()> _ Public Class EconomicsSummary Public Sub New() RecentTransactions = New List(Of Transaction) TotalAccountHistory = New List(Of Transaction) End Sub Public Sub New(ByVal enUser As EntityUser) Me.UserId = enUser.UserId Me.UserName = enUser.UserName Me.Accounts = enUser.Accounts Me.Jobs = enUser.Jobs RecentTransactions = New List(Of Transaction) TotalAccountHistory = New List(Of Transaction) End Sub <DataMember()> _ <Key()> _ Public Property UserId As System.Guid <DataMember()> _ Public Property NumTransactions As Integer <DataMember()> _ <Include()> _ <Association("Summary_RecentTransactions", "UserId", "User_UserId")> _ Public Property RecentTransactions As List(Of Transaction) <DataMember()> _ <Include()> _ <Association("Summary_TotalAccountHistory", "UserId", "User_UserId")> _ Public Property TotalAccountHistory As List(Of Transaction) End Class Next, the relevant parts of the function called to return the object: Public Function GetEconomicsSummary(ByVal guidUserId As System.Guid) As EconomicsSummary Dim objOutput As New EconomicsSummary(enUser) For Each objTransaction As Transaction In (From t As Transaction In Me.ObjectContext.Transactions.Include("Account") Where t.Account.aspnet_User_UserId = guidUserId Select t Order By t.TransactionDate Descending Take 10) objTransaction.User_UserId = objOutput.UserId objOutput.RecentTransactions.Add(objTransaction) Next objOutput.NumTransactions = objOutput.RecentTransactions.Count … Return objOutput End Function Notice that I’m collecting the NumTransactions count before serialization. Should be 10 right? It is – BEFORE serialization. The DataGrid is bound to the data source as follows: <sdk:DataGrid AutoGenerateColumns="False" Height="100" MaxWidth="{Binding ElementName=aciSummary, Path=ActualWidth}" ItemsSource="{Binding Source={StaticResource EconomicsSummaryRecentTransactionsViewSource}, Mode=OneWay}" Name="gridRecentTransactions" RowDetailsVisibilityMode="VisibleWhenSelected" IsReadOnly="True"> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn x:Name="TransactionDateColumn" Binding="{Binding Path=TransactionDate, StringFormat=\{0:d\}}" Header="Date" Width="SizeToHeader" /> <sdk:DataGridTextColumn x:Name="AccountNameColumn" Binding="{Binding Path=Account.Title}" Header="Account" Width="SizeToCells" /> <sdk:DataGridTextColumn x:Name="CurrencyAmountColumn" Binding="{Binding Path=CurrencyAmount, StringFormat=\{0:c\}}" Header="Amount" Width="SizeToHeader" /> <sdk:DataGridTextColumn x:Name="TitleColumn" Binding="{Binding Path=Title}" Header="Description" Width="SizeToCells" /> <sdk:DataGridTextColumn x:Name="ItemQuantityColumn" Binding="{Binding Path=ItemQuantity}" Header="Qty" Width="SizeToHeader" /> </sdk:DataGrid.Columns> </sdk:DataGrid> You might be wondering where the ItemsSource is coming from, that looks like this: <CollectionViewSource x:Key="EconomicsSummaryRecentTransactionsViewSource" Source="{Binding Path=DataView.RecentTransactions, ElementName=EconomicsSummaryDomainDataSource}" /> When I noticed that the DataGrid had the extra row I tried outputting some data after the data source finishes loading, as follows: Private Sub EconomicsSummaryDomainDataSource_LoadedData(ByVal sender As System.Object, ByVal e As System.Windows.Controls.LoadedDataEventArgs) Handles EconomicsSummaryDomainDataSource.LoadedData If e.HasError Then System.Windows.MessageBox.Show(e.Error.ToString, "Load Error", System.Windows.MessageBoxButton.OK) e.MarkErrorAsHandled() End If Dim objSummary As EconomicsSummary = CType(EconomicsSummaryDomainDataSource.Data(0), EconomicsSummary) Dim sb As New StringBuilder("") sb.AppendLine(String.Format("Num Transactions: {0} ({1})", objSummary.RecentTransactions.Count.ToString(), objSummary.NumTransactions.ToString())) For Each objTransaction As Transaction In objSummary.RecentTransactions sb.AppendLine(String.Format("Recent TransactionId {0} dated {1} CurrencyAmount {2} NewBalance {3}", objTransaction.TransactionId.ToString, objTransaction.TransactionDate.ToString("d"), objTransaction.CurrencyAmount.ToString("c"), objTransaction.NewBalance.ToString("c"))) Next txtDebug.Text = sb.ToString() End Sub Output from that looks like this: Num Transactions: 11 (10) Recent TransactionId 2283 dated 6/1/2010 CurrencyAmount $31.00 NewBalance $392.00 Recent TransactionId 2281 dated 5/31/2010 CurrencyAmount $33.00 NewBalance $361.00 Recent TransactionId 2279 dated 5/28/2010 CurrencyAmount $8.00 NewBalance $328.00 Recent TransactionId 2277 dated 5/26/2010 CurrencyAmount $22.00 NewBalance $320.00 Recent TransactionId 2275 dated 5/24/2010 CurrencyAmount $5.00 NewBalance $298.00 Recent TransactionId 2273 dated 5/21/2010 CurrencyAmount $19.00 NewBalance $293.00 Recent TransactionId 2271 dated 5/20/2010 CurrencyAmount $20.00 NewBalance $274.00 Recent TransactionId 2269 dated 5/19/2010 CurrencyAmount $48.00 NewBalance $254.00 Recent TransactionId 2267 dated 5/18/2010 CurrencyAmount $42.00 NewBalance $206.00 Recent TransactionId 2265 dated 5/14/2010 CurrencyAmount $5.00 NewBalance $164.00 Recent TransactionId 0 dated 6/1/2010 CurrencyAmount $0.00 NewBalance $361.00 So I have a few different questions: -First and foremost, where the devil is that extra Transaction entity coming from and how do I get rid of it? Does it have anything to do with the other list of Transaction entities being serialized as part of the EconomicsSummary class (TotalAccountHistory)? Do I need to decorate the EconomicsSummary class members a little more/differently? -Second, where are the peculiar values coming from on that extra entity? PRE-POSTING UPDATE 1: I did a little checking, it looks like that last entry is the first one in the TotalAccountHistory list. Do I need to do something with CollectionDataContract()? PRE-POSTING UPDATE 2: I fixed one bug in TotalAccountHistory, since the objects weren’t coming from the database their keys weren’t unique. So I set the keys on the Transaction entities inside TotalAccountHistory to be unique and guess what? Now, after deserialization RecentTransactions contains all its original items, plus every item in TotalAccountHistory. I’m pretty sure this has to do with the deserializer getting confused by two collections of the same type. But I don’t yet know how to resolve it…

    Read the article

  • Hidden features of WPF and XAML?

    - by Sauron
    Here is a large number of hidden features discussed for variety of languages. Now I am curious about some hidden features of XAML and WPF? One I have found is the header click event of a ListView <ListView x:Name='lv' Height="150" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"> The GridViewColumnHeader.Click property is not listed. Some of relevant features so far: Multibinding combined with StringFormat TargetNullValue to bindings TextTrimming property Markup extensions Adding Aero effect to Window Advanced "caption" properties XAML Converters See also: Hidden features of C# Hidden features of Python Hidden features of ASP.NET Hidden features of Perl Hidden features of Java Hidden features of VB.NET Hidden features of PHP Hidden features of Ruby Hidden features of C And So On........

    Read the article

  • Silverlight HeaderStyle Broken?

    - by zburns
    Why does this not render correctly? <sdk:DataGrid AutoGenerateColumns="False" Height="438" HorizontalAlignment="Left" Margin="12,183,0,0" Name="dataGridWorkingGrid" VerticalAlignment="Top" Width="856" ClipboardCopyMode="IncludeHeader" CanUserReorderColumns="False" CanUserResizeColumns="False"> <sdk:DataGrid.Columns> <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="BatchID" IsReadOnly="True" Visibility="Collapsed" Width="Auto" Binding="{Binding BatchID}"/> <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Transaction Date" IsReadOnly="True" Width="100" Binding="{Binding TransactionDate, StringFormat='MM/dd/yyyy'}"> <sdk:DataGridTextColumn.HeaderStyle> <Style TargetType="TextBlock"> <Setter Property="TextWrapping" Value="Wrap"/> </Style> </sdk:DataGridTextColumn.HeaderStyle> </sdk:DataGridTextColumn> <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Merchant Name" IsReadOnly="True" Width="200" Binding="{Binding MerchantName}"/> </sdk:DataGrid.Columns> </sdk:DataGrid>

    Read the article

  • Unable to bind with any property of UserControl

    - by Agha Khan
    I looked your answer where I was also using this.DataContext=this. I am unable to convince myself why I have to remove it? But I did In my UserControl control I have 6 int properties (RedCount, GreenCount …) I am using .NET 3.5 and basically I wanted to use StringFormat with Binding. In my xaml file I have 6 Labels with I would like to bind, and I did what exactly you told in last reply. For some strange reasons it didn’t work. I don't know why it does not work. I placed break point in converter where I never hit it. This imples Binding failed.

    Read the article

  • Content alignment for Gridviewcolumn in the listview

    - by Pankaj Upadhyay
    Please see the picture below Following is the code for this :: <Grid> <ListView Style="{StaticResource listViewStyle}" Name="transactionListView" HorizontalAlignment="Stretch" VerticalAlignment="Top" ItemsSource="{Binding}" MouseDoubleClick="transactionListView_MouseDoubleClick" IsSynchronizedWithCurrentItem="True" > <ListView.View> <GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderColumnStyle}"> <GridView.Columns> <GridViewColumn Width="70" Header="Serial" DisplayMemberBinding="{Binding Path=Serial}" /> <GridViewColumn Width="100" Header="Date" DisplayMemberBinding="{Binding Path=Date, StringFormat={}{0:dd-MM-yyyy}}" /> <GridViewColumn Width="200" Header="Seller" DisplayMemberBinding="{Binding Path=Seller}" /> <GridViewColumn Width="200" Header="Buyer" DisplayMemberBinding="{Binding Path=Buyer}" /> <GridViewColumn Width="70" Header="Bales" DisplayMemberBinding="{Binding Path=Bales}" /> </GridView.Columns> </GridView> </ListView.View> </ListView> </Grid>

    Read the article

  • Text Trimming in Silverlight 4

    - by dwahlin
    Silverlight 4 has a lot of great features that can be used to build consumer and Line of Business (LOB) applications. Although Webcam support, RichTextBox, MEF, WebBrowser and other new features are pretty exciting, I’m actually enjoying some of the more simple features that have been added such as text trimming, built-in wheel scrolling with ScrollViewer and data binding enhancements such as StringFormat. In this post I’ll give a quick introduction to a simple yet productive feature called text trimming and show how it eliminates a lot of code compared to Silverlight 3. The TextBlock control contains a new property in Silverlight 4 called TextTrimming that can be used to add an ellipsis (…) to text that doesn’t fit into a specific area on the user interface. Before the TextTrimming property was available I used a value converter to trim text which meant passing in a specific number of characters that I wanted to show by using a parameter: public class StringTruncateConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int maxLength; if (int.TryParse(parameter.ToString(), out maxLength)) { string val = (value == null) ? null : value.ToString(); if (val != null && val.Length > maxLength) { return val.Substring(0, maxLength) + ".."; } } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion } To use the StringTruncateConverter I'd define the standard xmlns prefix that referenced the namespace and assembly, add the class into the application’s Resources section and then use the class while data binding as shown next: <TextBlock Grid.Column="1" Grid.Row="3" ToolTipService.ToolTip="{Binding ReportSummary.ProjectManagers}" Text="{Binding ReportSummary.ProjectManagers, Converter={StaticResource StringTruncateConverter},ConverterParameter=16}" Style="{StaticResource SummaryValueStyle}" /> With Silverlight 4 I can define the TextTrimming property directly in XAML or use the new Property window in Visual Studio 2010 to set it to a value of WordEllipsis (the default value is None): <TextBlock Grid.Column="1" Grid.Row="4" ToolTipService.ToolTip="{Binding ReportSummary.ProjectCoordinators}" Text="{Binding ReportSummary.ProjectCoordinators}" TextTrimming="WordEllipsis" Style="{StaticResource SummaryValueStyle}"/> The end result is a nice trimming of the text that doesn’t fit into the target area as shown with the Coordinator and Foremen sections below. My data binding statements are now much smaller and I can eliminate the StringTruncateConverter class completely.   For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit http://www.thewahlingroup.com.

    Read the article

  • IOException: Unable To Delete Images Due To File Lock

    - by Arslan Pervaiz
    I am Unable To Delete Image File From My Server Path It Gaves Error That The Process Cannot Access The File "FileName" Because it is being Used By Another Process. I Tried Many Methods But Still All In Vain. Please Help me Out in This Issue. Here is My Code Snippet. using System; using System.Data; using System.Web; using System.Data.SqlClient; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Globalization; using System.Web.Security; using System.Text; using System.DirectoryServices; using System.Collections; using System.IO; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; //============ Main Block ================= byte[] data = (byte[])ds.Tables[0].Rows[0][0]; MemoryStream ms = new MemoryStream(data); Image returnImage = Image.FromStream(ms); returnImage.Save(Server.MapPath(".\\TmpImages\\SavedImage.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg); returnImage.Dispose(); \\ I Tried this Dispose Method To Unlock The File But Nothing Done. ms.Close(); \\ I Tried The Memory Stream Close Method Also But Its Also Not Worked For Me. watermark(); \\ Here is My Water Mark Method That Print Water Mark Image on My Saved Image (Image That is Converted From Byte Array) DeleteImages(); \\ Here is My Delete Method That I Call To Delete The Images //===== ==== My Delete Method To Delete Files================== public void DeleteImages() { try { File.Delete(Server.MapPath(".\\TmpImages\\WaterMark.jpg")); \\This Image Deleted Fine. File.Delete(Server.MapPath(".\\TmpImages\\SavedImage.jpg")); \\ Exception Thrown On Deleting of This Image. } catch (Exception ex) { LogManager.LogException(ex, "Error in Deleting Images."); Master.ShowMessage(ex.Message, true); } } \ ==== Method Declartion That Make Watermark of One Image On Another Image.======= public void watermark() { //create a image object containing the photograph to watermark Image imgPhoto = Image.FromFile(Server.MapPath(".\\TmpImages\\SavedImage.jpg")); int phWidth = imgPhoto.Width; int phHeight = imgPhoto.Height; //create a Bitmap the Size of the original photograph Bitmap bmPhoto = new Bitmap(phWidth, phHeight, PixelFormat.Format24bppRgb); bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); //load the Bitmap into a Graphics object Graphics grPhoto = Graphics.FromImage(bmPhoto); //create a image object containing the watermark Image imgWatermark = new Bitmap(Server.MapPath(".\\TmpImages\\PrintasWatermark.jpg")); int wmWidth = imgWatermark.Width; int wmHeight = imgWatermark.Height; //Set the rendering quality for this Graphics object grPhoto.SmoothingMode = SmoothingMode.AntiAlias; //Draws the photo Image object at original size to the graphics object. grPhoto.DrawImage( imgPhoto, // Photo Image object new Rectangle(0, 0, phWidth, phHeight), // Rectangle structure 0, // x-coordinate of the portion of the source image to draw. 0, // y-coordinate of the portion of the source image to draw. phWidth, // Width of the portion of the source image to draw. phHeight, // Height of the portion of the source image to draw. GraphicsUnit.Pixel); // Units of measure //------------------------------------------------------- //to maximize the size of the Copyright message we will //test multiple Font sizes to determine the largest posible //font we can use for the width of the Photograph //define an array of point sizes you would like to consider as possiblities //------------------------------------------------------- //Define the text layout by setting the text alignment to centered StringFormat StrFormat = new StringFormat(); StrFormat.Alignment = StringAlignment.Center; //define a Brush which is semi trasparent black (Alpha set to 153) SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(153, 0, 0, 0)); //define a Brush which is semi trasparent white (Alpha set to 153) SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(153, 255, 255, 255)); //------------------------------------------------------------ //Step #2 - Insert Watermark image //------------------------------------------------------------ //Create a Bitmap based on the previously modified photograph Bitmap Bitmap bmWatermark = new Bitmap(bmPhoto); bmWatermark.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution); //Load this Bitmap into a new Graphic Object Graphics grWatermark = Graphics.FromImage(bmWatermark); //To achieve a transulcent watermark we will apply (2) color //manipulations by defineing a ImageAttributes object and //seting (2) of its properties. ImageAttributes imageAttributes = new ImageAttributes(); //The first step in manipulating the watermark image is to replace //the background color with one that is trasparent (Alpha=0, R=0, G=0, B=0) //to do this we will use a Colormap and use this to define a RemapTable ColorMap colorMap = new ColorMap(); //My watermark was defined with a background of 100% Green this will //be the color we search for and replace with transparency colorMap.OldColor = Color.FromArgb(255, 0, 255, 0); colorMap.NewColor = Color.FromArgb(0, 0, 0, 0); ColorMap[] remapTable = { colorMap }; imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap); //The second color manipulation is used to change the opacity of the //watermark. This is done by applying a 5x5 matrix that contains the //coordinates for the RGBA space. By setting the 3rd row and 3rd column //to 0.3f we achive a level of opacity float[][] colorMatrixElements = { new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, 0.3f, 0.0f}, new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}}; ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements); imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //For this example we will place the watermark in the upper right //hand corner of the photograph. offset down 10 pixels and to the //left 10 pixles int xPosOfWm = ((phWidth - wmWidth) - 10); int yPosOfWm = 10; grWatermark.DrawImage(imgWatermark, new Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight), //Set the detination Position 0, // x-coordinate of the portion of the source image to draw. 0, // y-coordinate of the portion of the source image to draw. wmWidth, // Watermark Width wmHeight, // Watermark Height GraphicsUnit.Pixel, // Unit of measurment imageAttributes); //ImageAttributes Object //Replace the original photgraphs bitmap with the new Bitmap imgPhoto = bmWatermark; grPhoto.Dispose(); grWatermark.Dispose(); //save new image to file system. imgPhoto.Save(Server.MapPath(".\\TmpImages\\WaterMark.jpg"), ImageFormat.Jpeg); imgPhoto.Dispose(); imgWatermark.Dispose(); }

    Read the article

  • WPF zoom canvas and maintain scroll position

    - by Alex McBride
    I have a Canvas element, contained within a ScrollViewer, which I'm zooming using ScaleTransform. However, I want to be able to keep the scroll position of the viewer focused on the same part of the canvas after the zoom operation has finished. Currently when I zoom the canvas the scroll position of the viewer stays where it was and the place the user was viewing is lost. I'm still learning WPF, and I've been going backwards and forwards a bit on this, but I can't figure out a nice XAML based way to accomplish what I want. Any help in this matter would be greatly appreciated and would aid me in my learning process. Here is the kind of code I'm using... <Grid> <ScrollViewer Name="TrackScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <Canvas Width="2560" Height="2560" Name="TrackCanvas"> <Canvas.LayoutTransform> <ScaleTransform ScaleX="{Binding ElementName=ZoomSlider, Path=Value}" ScaleY="{Binding ElementName=ZoomSlider, Path=Value}"/> </Canvas.LayoutTransform> <!-- Some complex geometry describing a motor racing circuit --> </Canvas> </ScrollViewer> <StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Top" HorizontalAlignment="Left"> <Slider Name="ZoomSlider" Width="80" Minimum="0.1" Maximum="10" Value="1"/> <TextBlock Margin="4,0,0,0" VerticalAlignment="Center" Text="{Binding ElementName=ZoomSlider, Path=Value, StringFormat=F1}"/> </StackPanel> </Grid>

    Read the article

  • WPF ComboBox IsSynchronised Default Value

    - by LnDCobra
    I am trying to display a default value (or even NO value) when selected index is -1, or selecteditem is null. This normally works perfectly fine but when I enable IsSynchronizedWithCurrentItem and set it to True, the first value in my DataTable gets displayed. How can I have both IsSynchronizedWithCurrentItem ="True" and show no/default value when it is loaded. My Combo Box XAML: <GroupBox Name="ClientGroup" Header="Client" Margin="63,182,0,177" FontSize="14" HorizontalAlignment="Left" Width="298"> <ComboBox Name="Supplier" Grid.IsSharedSizeScope="True" ItemsSource="{Binding}" IsEditable="True" Text="Please Choose..." TextSearch.TextPath="CompanyName" IsSynchronizedWithCurrentItem="True" Height="23" VerticalAlignment="Top" Margin="0,6,6,0" FontSize="11" StaysOpenOnEdit="True"> <ComboBox.ItemTemplate> <DataTemplate> <Grid Margin="0,5,0,5"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="CompanyName" /> <ColumnDefinition Width="Auto" SharedSizeGroup="EIC" /> </Grid.ColumnDefinitions> <TextBlock Text="{Binding CompanyName}" Grid.Column="0" /> <TextBlock Text="{Binding EIC, StringFormat=' ({0})'}" Grid.Column="1" FontFamily="Courier New" FontWeight="Bold" FontSize="12" /> </Grid> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> </GroupBox> My CS code behind: ClientGroup.DataContext = (new CompanyDealsDataSetTableAdapters.CompanyTableAdapter()).GetData(); When I start my application it automatically selects the first row in my data table. It works as expected when I remove IsSynchronizedWithCurrentItem. Any ideas?

    Read the article

  • WPF - Byte Array to Hex View (similar to Notepad++ HEX-Editor plugin)

    - by tenfour
    I am using an ItemsControl to display a List<byte> in hex. The ItemsPanelTemplate is a UniformGrid with a fixed number of columns: <ItemsControl HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="16"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding StringFormat='\{0:X2\}'}" Margin="5,5,5,0"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> I'd like to prefix each row with an 'Address' column, just like you'd see with the Notepad++ 'HEX-Editor' plugin. That is, since I have 16 columns, each row should be prefixed something like this: 0000 [00 01 02 .... 0F] 0010 [10 11 12 .... 1F] 0020 [20 21 22 .... 2F] ... Any suggestions?

    Read the article

  • XAML ContextMenu gets bound to wrong row in a DataGrid

    - by Simon_Weaver
    I have a XAML based ContextMenu bound to the rows in a datagrid. It works just fine - until the grid is scrolled! This is the context menu for one of the controls in the visual tree or a DataGrid row. <data:DataGridTemplateColumn Header="Customer Details" Width="*"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid Background="Transparent"> <!-- allows click in entire cell --> <controlsInputToolkit:ContextMenuService.ContextMenu> <controlsInputToolkit:ContextMenu> <controlsInputToolkit:MenuItem Header="{Binding CompletedOrderId,StringFormat='Create Reminder for order #\{0\}'}" CommandParameter="{Binding}"> <controlsInputToolkit:MenuItem.Command> <command:CreateReminderCommand/> </controlsInputToolkit:MenuItem.Command> <controlsInputToolkit:MenuItem.Icon> <Viewbox> <Image Width="19" Height="18" Source="../images/reminders.png" VerticalAlignment="Center"/> </Viewbox> </controlsInputToolkit:MenuItem.Icon> </controlsInputToolkit:MenuItem> <controlsInputToolkit:ContextMenu> <controlsInputToolkit:ContextMenuService.ContextMenu> ...... The ICommand is CreateReminderCommand and the CommandParameter is bound to the data item for the row itself. This works just fine - I can right click on a row and it will show me the correct text in the menu item 'Create Reminder for order 12345'. Then I scroll the datagrid down a page. If I keep right clicking on items then suddenly I'll see the wrong order number for a row. I think what must be happening is this : The DataGrid is reusing instances of MenuItem that it has previously created. How can I force a refresh of the ContextMenu when it is displayed for an item that changes? There's no 'Update method on the ContextMenu or ContextMenuService.

    Read the article

  • Row Prefix - ItemsControl with UniformGrid

    - by tenfour
    I am using an ItemsControl to display a List<byte> in hex. The ItemsPanelTemplate is a UniformGrid with a fixed number of columns: <ItemsControl HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="16"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding StringFormat='\{0:X2\}'}" Margin="5,5,5,0"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> I'd like to prefix each row with an 'Address' column, just like you'd see with the Notepad++ 'HEX-Editor' plugin. That is, since I have 16 columns, each row should be prefixed something like this: 0000 [00 01 02 .... 0F] 0010 [10 11 12 .... 1F] 0020 [20 21 22 .... 2F] ... Any suggestions?

    Read the article

  • WPF CollectionViewSource Grouping

    - by Miles
    I'm using a Collection View Source to group my data. In my data, I have Property1 and Property2 that I'm needing to group on. The only stipulation is that I don't want sub-groups of another group. So, when I group by these two properties, I don't want to have it so that Property2 because a subgroup of Property1's group. The reason why I'm wanting this is because I'm wanting to have a header that shows the following information: Header: <TextBlock.Text> <MultiBinding StringFormat="Property1: {0}, Property2: {1}"> <Binding Path="Property1"/> <Binding Path="Property2"/> </MultiBinding> </TextBlock.Text> I've tried this with my CollectionViewSource but was not able to "combine" the group and subgroup together: <CollectionViewSource x:Key="myKey" Source="{Binding myDataSource}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="Property1" /> <PropertyGroupDescription PropertyName="Property2" /> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> Is it possible to group two properties together? Something like below? <CollectionViewSource x:Key="myKey" Source="{Binding myDataSource}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="Property1,Property2" /> </CollectionViewSource.GroupDescriptions> </CollectionViewSource>

    Read the article

  • How not to lose binding source updates?

    - by Fyodor Soikin
    Suppose I have a modal dialog with a textbox and OK/Cancel buttons. And it is built on MVVM - i.e. it has a ViewModel object with a string property that the textbox is bound to. Say, I enter some text in the textbox and then grab my mouse and click "OK". Everything works fine: at the moment of click, the textbox loses focus, which causes the binding engine to update the ViewModel's property. I get my data, everybody's happy. Now suppose I don't use my mouse. Instead, I just hit Enter on the keyboard. This also causes the "OK" button to "click", since it is marked as IsDefault="True". But guess what? The textbox doesn not lose focus in this case, and therefore, the binding engine remains innocently ignorant, and I don't get my data. Dang! Another variation of the same scenario: suppose I have a data entry form right in the main window, enter some data into it, and then hit Ctrl+S for "Save". Guess what? My latest entry doesn't get saved! This may be somewhat remedied by using UpdateSourceTrigger=PropertyChanged, but that is not always possible. One obvious case would be the use of StringFormat with binding - the text keeps jumping back into "formatted" state as I'm trying to enter it. And another case, which I have encountered myself, is when I have some time-consuming processing in the viewmodel's property setter, and I only want to perform it when the user is "done" entering text. This seems like an eternal problem: I remember trying to solve it systematically from ages ago, ever since I've started working with interactive interfaces, but I've never quite succeeded. In the past, I always ended up using some sort of hacks - like, say, adding an "EnsureDataSaved" method to every "presenter" (as in "MVP") and calling it at "critical" points, or something like that... But with all the cool technologies, as well as empty hype, of WPF, I expected they'd come up with some good solution.

    Read the article

  • GDI+ not clearing my window on repaint for vista

    - by Michael
    on WM_PAINT i do the following: //RectF mNameRect; //WCHAR* mName; //HWND mWin; // this is the window handle { PAINTSTRUCT ps; HDC hdc = BeginPaint(mWin, &ps); Graphics g(hdc); g.Clear(Color::White); StringFormat stringForm; stringForm.SetLineAlignment(StringAlignmentCenter); stringForm.SetAlignment(StringAlignmentCenter); // set the rectangle to the size of the whole window mNameRect.Width = static_cast<float>(size.cx); mNameRect.Height = static_cast<float>(size.cy); g.DrawString(mName, -1, &mNameFont, mNameRect, &stringForm, &mNameBrush); EndPaint(mWin, &ps); } In XP this works fine, the mName is displayed in the middle of the window. However on Vista the text doesn't move, it stays in its location no matter how I resize the window. the g.Clear(Color::White) doesn't seem to do any difference. The text doesn't even change position when the window is hidden behind another window and on focus needs to be repainted again. How do I make mName change position in Vista?

    Read the article

< Previous Page | 1 2 3  | Next Page >