So I dont really touch or have touched silverlight programming but my company has this application built in it and I have a bug they want me to fix. The issue is my text box can hold up to about 778 characters or 16 rows but then you cant view anymore of what you wrote. If you copy all you get everything you wrote even though you might only see 3/4 of it. I am not sure what I need to do, if I need to create a control panel thing for over flow or set a max length, etc. What would be my best step for this? Any good ideas?
Code:
<TextBox HorizontalAlignment="Left" Name="txtDesc" Width="300" Height="80" Grid.Column="1" Grid.Row="0" TextWrapping="Wrap" Text="{Binding Path=ExcursionDescription, Mode=TwoWay, Converter={StaticResource StripNonAsciilCharacters1}}" VerticalScrollBarVisibility="Auto" Margin="0,0,5,0"/>
Related
I have a WPF control with a button, whose command is bound to a DevExpress DocumentPreviewControl PageSetupCommand. However, this button always appears to be automatically greyed out.
<Button Content="Page Setup"
Command="{Binding PageSetupCommand, ElementName=binReportPrintSettings}"
MinWidth="90" MaxHeight="36" HorizontalAlignment="Left" Margin="8,0"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}"
IsEnabled="True"/>
.
.
.
<dxp:DocumentPreviewControl Grid.Column="2" CommandBarStyle="None"
x:Name="binReportPrintSettings" FocusVisualStyle="{x:Null}" ZoomMode="FitToWidth"
DocumentSource="{Binding Model.Report}"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}" />
After a bit of debugging, I've found that the binReportPrintSettings.PageSetupCommand.CanExecute() returns false which I'm thinking is the reason for this.
So for full disclosure - The Model.Report which the DocumentPreviewControl is bound to is null
(though I've also tried with a new XtraReport()). The reason for this is that what I actually plan to print is a PDF report which was supplied as binary data. The preview is actually displayed by a separate PdfViewerControl.
<dxpdf:PdfViewerControl Name="pdfReportViewer" DetachStreamOnLoadComplete="True"
DocumentSource="{Binding Model.BinaryReport.Data}"
CommandBarStyle="None" NumberOfRecentFiles="0" IsReadOnly="True"
ZoomMode="FitToVisible" ShowOpenFileOnStartScreen="False"
Visibility="{Binding Model.IsBinaryReportAvailable, Converter={StaticResource BoolToVisibilityConverter}}">
</dxpdf:PdfViewerControl>
But the PdfViewerControl doesn't have a PageSetupCommand, and the DocumentPreviewControl can't accept an array of bytes / Memory stream as a DocumentSource (at least not for a PDF).
So my question is, is there a way I can display the PageSetupCommand (or the same Dialog box in some way) in this situation?
This is something that has bothered me for some time, and I'm not sure if it's some setting that can be turned off or not, but whenever I copy and paste something in xaml in VS 2010 it always auto-indents the line that I'm on and often the one after it for some reason. For example, say I have these lines of xaml code:
<TextBlock VerticalAlignment="Top" Foreground="Red" FontSize="11" Width="5"
Text="*" Visibility="{Binding Path=ShowInvalidFlag,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Width="Auto" Background="Transparent" Text="{Binding Path=QuestionValue}" />
and then I realize that the first TextBlock needs a Margin defined and I copy Margin="0,1,0,0" from another control within the same xaml document and paste it within the declaration of the above TextBlock it auto-indents and I end up with this:
<TextBlock VerticalAlignment="Top" Margin="0,1,0,0" Foreground="Red" FontSize="11" Width="5"
Text="*" Visibility="{Binding Path=ShowInvalidFlag,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Width="Auto" Background="Transparent" Text="{Binding Path=QuestionValue}" />
Why is it doing this? It doesn't even have to be copied from the same xaml file or even xaml code (I just tried copying random text from a text file and pasted it within the control and it still auto-indented). It's quite frustrating that every time I paste something in xaml I need to re-adjust my indentation.
Converted from comment:
If you search in the options in VS you should be able to find under Text Editor and Xaml an option for Indenting. By default it's set to "smart" which isn't always as smart as you might want it to be. Play around with that and see if it's more comfortable for you. Copy / pasting seems to be particularly prone to tripping it up.
In addition, you can also always so to "Edit" -> "Advanced" and then either "Format Document" or "Format Selection" to force Visual Studio to take another pass at formatting which may either fix, or make worse, your problem.
I think the problem is that it tries to optimize between speed and correctness. When you paste something it may not consider the entire context of where you are pasting and instead only look at the immediate parent and / or siblings which is a problem when you are pasting in a whole bunch of stuff.
I am trying to show around 1400items in a LongListSelector. Though it displays items correctly, at times, when I scroll down to the bottom so quickly and then starts scrolling up, it doesn't show all the items, it hardly shows 100items despite the content of binded collection is not changed in the backend.
this is my UI code:
<phone:PanoramaItem Header="Monitors" Margin="{StaticResource PanoramaItemMargin}" HeaderTemplate="{StaticResource PanoramaItemHeaderTemplate}">
<phone:LongListSelector ItemsSource="{Binding MonitorRenderList}" VirtualizingStackPanel.VirtualizationMode="Recycling" Margin="-15,-15,0,0">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<common:MonitorListTemplateSelector Content="{Binding}" HorizontalAlignment="Left">
<common:MonitorListTemplateSelector.MonitorBucket>
<DataTemplate>
<TextBlock Text="{Binding titleUpperCase}" Margin="0,5,10,5" FontWeight="Bold" Foreground="{StaticResource AppForegroundHighlightTextBrush}" TextWrapping="NoWrap" TextTrimming="WordEllipsis" FontSize="{StaticResource RowHeaderFontSize}"/>
</DataTemplate>
</common:MonitorListTemplateSelector.MonitorBucket>
<common:MonitorListTemplateSelector.MonitorDetails>
<DataTemplate>
<TextBlock Text="{Binding monitorName}" Margin="0,5,10,5" FontSize="{StaticResource TextRowFontSize}" Foreground="{StaticResource AppForegroundNormalTextBrush}" TextWrapping="NoWrap" TextTrimming="WordEllipsis">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<i:InvokeCommandAction Command="{Binding DataContext.SelectedMonitorDetailsCommand, ElementName=LandingPageRoot, Mode=OneTime}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</DataTemplate>
</common:MonitorListTemplateSelector.MonitorDetails>
<common:MonitorListTemplateSelector.EmptyLastItem>
<DataTemplate>
<TextBlock Height="72" />
</DataTemplate>
</common:MonitorListTemplateSelector.EmptyLastItem>
</common:MonitorListTemplateSelector>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</phone:PanoramaItem>
EDIT: this problem seems to occur only when LongListSelector is contained in Panorama even if there is just a single panoramaItem, but when I move it out of the panorama it doesn't happen.
This is normal behavior and it is caused from the build-in virtualization of the control. When you data bound collections are too large, virtualization kicks in order to keep the performance of the control intact.
Without UI virtualization the entire data set would be kept in memory and an item container would be created for each one of your items in the list, crippling the performance of your app and possibly throwing an OutOfMemoryException that would terminate it.
With UI virtualization the data set is still kept in memory, but an item container is created only when the item is nearly ready to be shown in the UI, keeping the memory consumption low.
By default all items controls enable UI virtualization.
EDIT
Taken from Daniel Vaughan's - Windows Phone 8 Unleashed, SAMS Publishing
As the Panorama is intended to coax the user to explore, it should show content that is
interesting and specific to the user. The user should also not be overloaded with too much
content; think white space and not loads of data. The Panorama should be thought of as
a starting place, containing data and links that take the user to more detailed pages of
content, pages that may include a Pivot for example. The user is then able to leave the
exploratory style of the Panorama for the more focused style of the Pivot.
also from this link: http://ux.artu.tv/?p=234
Panoramas can’t hold large amounts of data. For performance and experience reasons do not use Panoramas if you have the need to present a large amount of content for users. How much is too much? In general stay within 3 to 5 Panorama panels. Use ListBoxes that use a maximum of 15-20 items. Panoramas are not virtualized (memory managed) so think of them almost as big flat images than dynamic content controls (like Pivots). Again, they are more of Magazine Covers - beautiful and immersive.
Each and every Silverlight controls for the Windows Phone have size restriction. It can be displayed maximum 2048 pixels in both Width and Height..
Your problem may occur due to this reason. Have you checked ?
I've got this really weird problem where I'm doing highlighting on certain parts of text on a TextBlock object containing multiple Run objects.
<TextBlock Name="InlineTextBlock" Background="White">
<Run Foreground="White"
Background="Blue"
FontSize="75"
FontFamily="Helvetica">17-Oct-13</Run>
<Run Foreground="White"
Background="Blue"
FontSize="75"
FontFamily="Helvetica">17/Oct/13</Run>
</TextBlock>
It's pretty straightforward code to read, and from reading, you would expect both 17-Oct-13 and 17/Oct/13 to be completely highlighted with a Blue Background and White Foreground.
The odd thing is, the hyphen character has 1 pixel on the left and the right where the Background color is not being applied.
There are no issues with highlighting for the second Run object with 17/Oct/13.
Would appreciate any help to figure out this odd problem.
EDIT:
Running this on my computer displays the following (you'll have to look really closely to see it):
Also, I noticed this only occurs on certain fonts like Helvetica, Arial, Consolas (to name a few). Verdana seems to display fine.
Unfortunately, running your code on my computer does not suffer from this problem:
I'm guessing that you have something else causing your problem.
For your information, I'm running Visual Studio 2010 on Windows 7 and .NET 4.0.
UPDATE >>>
Thanks for the update... I can now confirm that I see your mysterious vertical white lines around the hyphens using the Helvetica font. I can't imagine what is causing it, but assuming that you can't set the main TextBlock.Background to Blue, you can still fix this issue by using an inner TextBlock with its Background set to Blue:
<TextBlock Name="InlineTextBlock" Background="White">
<TextBlock Background="Blue">
<Run Foreground="White"
Background="Blue"
FontSize="50"
FontFamily="Helvetica">17-Oct-13</Run>
<Run Foreground="White"
Background="Blue"
FontSize="50"
FontFamily="Helvetica">17/Oct/13</Run>
</TextBlock>
</TextBlock>
I'm guessing these don't exist since I searched around for these but I'm looking for a few tools:
1) A tool that cleans up my xaml so that the properties of elements are consistent through a file. I think enforcing that consistence would make the xaml easier to read. Maybe there could be a hierarchy of what comes first but if not alphabetical might work.
Example before:
TextBox Name="myTextBox1" Grid.Row="3" Grid.Column="1" Margin="4"
TextBox Grid.Column="1" Margin="4" Name="t2" Grid.Row="3"
Example after:
TextBox Name="myTextBox1" Grid.Row="3" Grid.Column="1" Margin="4"
TextBox Name="t2" Grid.Row="3" Grid.Column="1" Margin="4"
(note < /> has been remove from the above since control seem to have issues parsing whe the after section was added)
2) Along the same lines as above, to increase readability, a tool to align properties, so from the above code example similar props would start in the same place.
<TextBox Name="myTextBox1" Grid.Row="3" Grid.Column="1" Margin="4"/>
<TextBox Name="t2" Grid.Row="3" Grid.Column="1" Margin="4"/>
I know VS has default settings for XAML documents so props can be on one line or separate lines so maybe if there was a tool as described in (1) this would not be needed...but it would still be nice if you like your props all on one line.
3) A tool that adds X to the any of the Grid.Row values and Y to any of the Grid.Column values in the selected text. Every time I add a new row\column I have to go manually fix these. From my understanding Expression Blend can help with this but seem excessive to open Blend just to increment some numbers (and just don't grok Blend). Maybe vs2010 with the designer will help but right now I'm on VS08 and Silverlight.
Any one know of any tools to help with this?
Anyone planning to write something like this...I'm looking at you JetBrains and\or DevExpress.
Thanks.
Try out Kaxaml. It has a couple auto-formatting tools like this.