|
Sometimes I'll type "this" if I don't remember the prop name, but I'll delete the this afterwards. I use a leading underscore (which Andy did) on class member variables. That differentiates member variables from local variables. I think very few people agree on formatting / style issues . In my last job, my team lead insisted everybody format the code with 3 spaces. It took me a while to convince him that nobody else likes 3 spaces and if he went to tabs, then everybody could have it how they wanted without affecting the code. He still put up a fight. Only once I showed him that practice in action and how SCC still saw it as exactly the same did the light bulb finally come on.
|
|
|
|
|
My pet hates are underscores, capitalisation and anyone not using TAB set you = 2 spaces (SSMS uses 8 ).
Even if you use tabs and the size of the tabs are different it can totally screw up the formatting when changing developer, irritating to say the least.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: My pet hates are underscores
+5 on that one. I think it makes code so unreadable.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
So how do you easily differentiate between local variables, method parameters and class members?
|
|
|
|
|
A common trick with VMs is to apply lazy-loading to your commands. What you do is
private RelayCommand loadCommand;
public RelayCommand LoadCommand
{
get
{
if (loadCommand == null)
loadCommand = new RelayCommand((o)=> LoadSomeViewExecute, new Predicate<object>(CanLoadExecute));
return loadCommand;
}
}
|
|
|
|
|
Cheers Pete, I have used lazy loading with CSLA and will definitely take a look at this.
I am quickly getting around C# syntax and 'un-learning' some VB hacks!
I don't speak Idiot - please talk slowly and clearly
"I have sexdaily. I mean dyslexia. Fcuk!"
Driven to the arms of Heineken by the wife
|
|
|
|
|
Hi Friends
I want the WPF for the VB.Net(WinForm) to make a of Components
The ElementHost do not want to use
Thank you
|
|
|
|
|
If you're going to be hosting WPF inside WinForms, then you need the ElementHost, or you're going to have to write your own, which will end up doing what ElementHost does anyway.
|
|
|
|
|
WPF and Winforms are different programming languages and you should try and use only one or the other.
You can call one type in another, but it should only be for legacy systems and really not for any new application.
|
|
|
|
|
|
I am looking for latest books or tutorials... not the old or outdated ones...Books or tutorials with hands-on or practical examples... Thanks.
|
|
|
|
|
Please check <a href="http://joshsmithonwpf.wordpress.com/advanced-mvvm/">http://joshsmithonwpf.wordpress.com/advanced-mvvm/</a>[<a href="http://joshsmithonwpf.wordpress.com/advanced-mvvm/" target="_blank" title="New Window">^</a>] from the WPF guru.
|
|
|
|
|
|
Try to avoid cross-posting.
This question was already answered in the C# forum.
|
|
|
|
|
Abhinav,
Thanks for your comments.. you are right... I recently joined code project... I was not familiar with the site when i joined... Initially I posted this question in C# discussion section... I did not see or realize the WPF/Silverlight forum... Then I posted the question here i thought this was the right place for this question... thanks for your feed back...I'll make sure I don't cross post question in the future...
|
|
|
|
|
|
Hi,
I'm trying to bind my ICollectionView data to a DataGrid and am not getting any data displayed, even though the data is retrieved from my data source.
I am trying to populate my DataGrid with data received as the result of a Button press, and can only assume that the problem is that my ICollectionView data is received on a separate thread. The data is received correctly, and my list is populated fully, but just not displayed.
My XAML is this
<Window x:Class="UPC_Programmer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UPCP="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:GridLines="clr-namespace:UPC_Programmer" Closing="Window_OnClosing"
xmlns:tree="clr-namespace:Aga.Controls.Tree;assembly=Aga.Controls"
x:Name="DataTree"
<ToolBarPanel Height="26" HorizontalAlignment="Stretch" Margin="1,22,0,4"
Name="toolBarPanel1" VerticalAlignment="Stretch" Width="800" Orientation="Horizontal"
Background="Gray" Grid.ColumnSpan="4">
<Button x:Name="Controller_Read" Height="25" Width="50" Click="OnReadBtnClk"
IsEnabled="False">
</Button>
</ToolBarPanel>
<DockPanel Height="448" Width="801" Grid.ColumnSpan="4"
Margin="0,51,0,29" Grid.RowSpan="2">
<UPCP:DataGrid DataContext="{StaticResource GroupedCustomers}" ItemsSource="{Binding}"
AutoGenerateColumns="False" Grid.Row="1" Height="447" HorizontalAlignment="Left"
Name="dataGrid2" VerticalAlignment="Top" Width="799" Grid.ColumnSpan="4">
<UPCP:DataGrid.Columns>
<UPCP:DataGridTextColumn Header="Parameter" Width="400"
Binding="{Binding Path=TagName}" Foreground="Black"/>
<UPCP:DataGridTextColumn Header="Value" Width="50"
Binding="{Binding Path=Value}" Foreground="Black"/>
<UPCP:DataGridTextColumn Header="" Width="50"
Binding="{Binding Path=Value3}" Foreground="Black"/>
</UPCP:DataGrid.Columns>
</UPCP:DataGrid>
</DockPanel>
</Window>
And my Code Behind is similar to that below
public partial class MyClass
{
public ICollectionView GroupedCustomers { get; private set; }
private MY_LIST<MY_VALUES> currentValueList = null;
private void OnReadBtnClk(object sender, RoutedEventArgs e)
{
RequestService(LIBRARY.LIB.OFFERED_SERVICES.GET_CURRENT_VALUES);
}
void OnValueListReceived(object sender, ValueListConnectionHandlerEventArgs e)
{
if (e.GetValueList.List != null)
{
this.currentValueList = e.GetValueList;
if (this.currentValueList.Count() > 0)
{
LoadData();
}
}
}
private void LoadData()
{
_TagCollection.Clear();
foreach(VALUES item in currentValueList)
{
try
{
if (item.GetValueType == TYPE_INT)
{
MemoryStream ms = item.GetValueStreamed;
BinaryFormatter bFormatter = new BinaryFormatter();
ms.Position = 0;
String strParam = item.GetIndex.ToString();
String strValue = item.GetSubIndex.ToString();
String strValue2 = item.GetPoohId.ToString();
String strValue3 = item.GetNodeId.ToString();
Group eGroup = GetGroupEnumFromID("1");
_TagCollection.Add(new TagData { TagName = strParam, Value = strValue, Value2 = strValue2, Value3 = strValue3, Group = eGroup });
}
}
catch
{
}
}
GroupedCustomers = new ListCollectionView(_TagCollection);
dataGrid2.Items.Refresh();
}
}
}
My list, GroupedCustomers, is populated with the right amount of data, but my dataGrid doesn't display the data.
Any thoughts would be much appreciated.
Regards
Tony
modified 9-Nov-12 3:08am.
|
|
|
|
|
Resolved now, amazing what a few months away can do to your memory.
Just using a simple delegate was all that was needed to post my list back to the original thread.
|
|
|
|
|
Let me explain the problem, I'm getting stuck in it
If I change the dpi settings from the dialog of Printing Preferences of a virtual printer like PDF Creator or any printer that allows to change this setting, and then set a breakpoint like the code below:
PrintDialog printDialog = new PrintDialog();
if ((bool)printDialog.ShowDialog().GetValueOrDefault())
{
System.Printing.PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities(printDialog.PrintTicket);
...... insert breakpoint here
}
I can see that the properties printDialog.PrintTicket.PageResolution.X; and printDialog.PrintTicket.PageResolution.Y change values correctly while printDialog.PrintTicket.PageMediaSize.Width and printDialog.PrintTicket.PageMediaSize.Height don't change despite the printer resolution change... an A4 paper in portrait mode will always have PageMediaSize.Height = 1122.5196850393702 and PageMediaSize.Width = 793.70078740157476 no matter which resolution is set before ..... for WPF the unit size of these dimensions is set to 1/96th inch but when is Ok on screen because default screen resolution is 96 dpi on the other side is wrong on the printer because it has a different resolution, in other words confuting that Height and Width of the paper are read only properties if I cannot find the way to tell WPF that the unit size of the printer is not 1/96th inch but for example 1/300th inch (if on the printer I previously set 300 dpi ) there's absolutely no way to print at higher resolution than 96dpi
A last note, in my specific case I cannot use RenderTargetBitmap and then resize all to match printer's paper height and width settings because I'm printing high definition barcode images and it would cause an image rescaling that would make the barcode unreadable on final paper because i create it with the purpose to be printed with a resolution of 300dpi which without a resizing will result out of bounds because WPF is telling me the printer paper dimensions in the wrong unit size (1/96th inch) despite the real dpis prevoiusly set on printer
Hoping to have clarified enough the problem,
thanks in advance,
Dave
PS
A hint to reproduce the issue is doing a printing with PrintVisual or PrintDocument methods with different printer resolution set before in the PrintDialog, the output will always be the same
modified 8-Nov-12 13:50pm.
|
|
|
|
|
Printing seems a tricky issue and I haven't done it in a while...
But at any rate I suspect it is correct. Because WPF doesn't use 'pixels' as unit of measure but.. 'device independent pixels' (or DIP for short), that means WPF will always think there are 96 DIP, whatever the DPI. And the underlying system will scale thing accordingly.
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi Lloyd, thanks for the comment
The problem was resolved drawing directly the lines of the barcode in a Canvas
Since WPF thinks, draws (and also prints) vectorial it hasn't any problem handling vectorial shapes (at this point the real limit is only given by the printer's physical resolution), viceversa it could have problems handling raster images because it's not the way it's used to think and, like you said before it plainly translates bitmap pixels to WPF units without any sort of scale, so at 96DPIs (unless you set a different DPI value from Control Panel --> Display Settings but that's a different story and not a viable option in my case because printers are not monitors and will always have different resolutions).
modified 20-Nov-12 5:07am.
|
|
|
|
|
I have issues with the C# WPF WebBrowser class
I have a C# WPF application which uses a WebBrowser class. I have overwritten the LoadComplete method. The question I have is this. This method is supposed to be triggered when the class has completed a load, but , when I put a breakpoint on this method, it is called before the class visually has compleded a load. Because of this, the htmldata is not complete. Any ideas?
Maybe there is a different method I should overide. LoadComplete might not be the best choice. Maybe there is something that is the same as a "display complete".
|
|
|
|
|
What do you mean when you say that "the htmldata is not complete"? You can access the mshtml.HTMLDocument object from the .Document property of the WebBrowser object in the LoadComplete event.
As for the "visuals", the page is rendered on the main UI thread. Since LoadComplete runs on the main UI thread (when the page has been loaded, but not yet displayed), the page will not display until LoadComplete exits ... unless you tell the thread's Dispatcher to process pending UI events (see DispatcherFrame in VS / C# Help).
|
|
|
|
|
It seems no amount of SnapsToDevicePixels="True" and/or UseLayoutRounding="True" can make the border around a Paragraph sharp:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocumentReader>
<FlowDocument>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</Window>
However i can use RenderOptions.EdgeMode="Aliased" which makes the border sharp, but distorts the Expander:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<FlowDocumentReader RenderOptions.EdgeMode="Aliased">
<FlowDocument>
<Paragraph BorderBrush="Black" BorderThickness="1" Padding="10">
<InlineUIContainer>
<Expander Header="An expander" >
<Button>A button</Button>
</Expander>
</InlineUIContainer>
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</Window>
So, is there any way to make the border sharp without hurting the documents appearance?
|
|
|
|
|
If you placed the Expanders (with a border) "outside" the FlowDocument (in a FrameworkElement), you could use UseLayoutRounding to get the effect you want.
As presented, I don't see why these expanders have to be inside a FlowDocument (which isn't a FrameworkElement).
|
|
|
|