Is there a standard naming convention for WPF UI controls?
.net, controls, naming-conventions, wpf
Solution
1) Control naming
Post suggested by Cody Gray should be sufficient WPF UI element naming conventions
2) Event naming
I prefer to use the same convention as Visual Studio "<ControlName>_<EventName>". When you type event name and hit TAB it generates method for you. Don't see any reason to spend time on renaming it, other than using it on multiple controls - in such case you'd want to provide some generic descriptive name for the handler.
3) Attributes order
Mine is: first name (if exists), events last. All other attributes should be grouped by their impact - appearance related (background, foreground, opacity, etc.), layout related (height, width, aligments), etc. Not to have "width" in top of your attributes list and "height" somewere in the bottom.
Problem
it exist some standard for notation of UI controls in WPF. Something like hungarian notation. For example ``` <TextBox Name=tbNameOfTextBox/> <Image Name=imgOfMe/> <RichTextBox Name="rtbDocument"/> ``` What kind of notation do you use? And my second question is about sequence, organization properties in element. Fot example I have this: ``` <ListBox Name="friendsListBox" ItemsSource="{Binding}" SelectedItem="Key" Style="{DynamicResource friendsListStyle}" PreviewMouseRightButtonUp="ListBox_PreviewMouseRightButtonUp" PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown" Grid.Row="2" Margin="4,4,4,4" MouseRightButtonDown="FriendsListBoxMouseRightButtonDown"> ``` or ``` <TextBox Name="TbStatus" Text="{Binding Path=Message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource CurveTextBox}" Grid.Column="1" TextWrapping="Wrap" Margin="3,3,3,3" LostFocus="TbStatus_LostFocus" /> ``` In listbox I have properties such as Name, ItemSource,SelectedItem, and som Events. What is appropriate to their organization. The first should be the name of the UI control, then the events and finally style properties?