DevExpress PageSetupCommand - button greyed out. (What is its CanExecute() method doing?) - wpf

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?

Related

Copy pasting things in xaml auto-indents?

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.

LongListSelector not diplaying all of the items after its scrolled so quickly

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 ?

Silverlight stopped displaying text after certain number of characters

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"/>

WPFToolkit:Split button dropdown button disable button

I am using WPF split button which is inherited from
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
The issue is I want to disable , the button ' the one below(Right side of Button 'Conf' in below 'downarrow present in the below fig) , If user clicks on Left side of the button the rightside should be disabled and the button(leftside) background should change to yellow.please find below the xaml , I am using the wpf split button , dropdown content in this case .please let me know if you have any idea
<extToolkit:SplitButton x:Name="ABCbutton"
VerticalAlignment="Center"
Command="{Binding ACommand}"
FontSize="16>
<TextBlock HorizontalAlignment="Center"
IsEnabled="{Binding IsEnabled, ElementName=AButton}"
Text="A"/>
<extToolkit:SplitButton.DropDownContent>
<StackPanel>
<Button Command="{Binding BCommand}"
Padding="3"
Style="{DynamicResource
DropDownButtonMenuButton}">
<TextBlock Margin="0,3,6,3"
Text="B"/>
</Button>
<Button Command="{Binding BCommand}"
Padding="3"
Style="{DynamicResource
DropDownButtonMenuButton}">
<TextBlock Margin="0,3,6,3"
HorizontalAlignment="Stretch"
Text="C"/>
</Button>
</StackPanel>
</extToolkit:SplitButton.DropDownContent>
</extToolkit:SplitButton>
In a case like this, you will likely be better off creating your own control. The split button can't really handle what you are talking about without a good deal of modification.
Essentially your new control will consist of two buttons, visually styled so that they look like they blend together. Each will have it's own background and enabled property. Add a ViewModel to help control behaviors and set properties, and I think you would be in business. Keep in mind that all of the controls that are supplied in any of the toolkits, frameworks, control packs, etc are made with the primitive types of drawing and framework elements (line, rectangle, border, content presenter, panel, etc) with specialized behavior code.
I end up making a lot of custom controls just because there is not one that perfectly replicates what I want.

Silverlight Label content binding problems

I'll preface this and say that I'm new to Silverlight development by about week so I'm most likely doing it wrong...
Anyway I have a Label and a TextBox done up thusly in XAML:
<dataInput:Label Target="{Binding ElementName=JobCode}" Height="18" HorizontalAlignment="Left" Margin="15,7,0,0" Name="lableJobCode" VerticalAlignment="Top" Width="250" FontWeight="Bold" Grid.Column="1" />
<TextBox Height="23" Text="{Binding SelectedRole.Job_Code}" HorizontalAlignment="Left" Margin="15,31,0,0" Name="JobCode" VerticalAlignment="Top" Width="277" Grid.Column="1" IsReadOnly="{Binding IsNotAdmin}" />
Everything works great, the only issue I have is that the binding I'm doing on the IsReadOnly attribute which goes to a boolean in my ViewModel which is set based on a call to an authentication service, is now overriding the label Content to the name of my ViewModel property: IsNotAdmin. I can't seem to find a way to specify which data binding source to pull the label content MetaData from. Maybe I'm missing something on how to manipulate control editablity/visibility from my ViewModel.
--Update: The data source class that the TextBox is bound to is as follows (for the relevant parts):
public class RoleSummary {
[Display(Name= "Job Code (To be Completed by HR):")]
public string Job_Code { get; set; }
Without the binding to the IsReadOnly attribute the Label displays the text from the data annotation just fine. When I add the binding it displays "IsNotAdmin"
can you post more of your code? I'm not entirely sure what it is that you're trying to make happen so it's hard to propose a solution.
I assume you're trying to create a text entry element that has validation performed on it (hence the label) -- but what exactly is the label supposed to be showing for it's content?
EDIT: I figured this out. The label control by default looks through all the properties in its datacontext looking for metadata it can use. For whatever reason it decided to use the metadata for the IsNotAdmin property in your code (even though you didn't set it manually, I assume that the Display metadata gets a default value of the property name), and so you get that for the text of the label.
Microsoft put in a property specifier into the data controls so you can tell it which property it should use for the metadata lookup: PropertyPath
Try it like this:
<dataInput:Label Target="{Binding ElementName=JobCode}" PropertyPath="SelectedRole.Job_Code" Height="18" HorizontalAlignment="Left" Margin="15,7,0,0" Name="lableJobCode" VerticalAlignment="Top" Width="250" FontWeight="Bold" Grid.Column="1" />
<TextBox Height="23" Text="{Binding SelectedRole.Job_Code}" HorizontalAlignment="Left" Margin="15,31,0,0" Name="JobCode" VerticalAlignment="Top" Width="277" Grid.Column="1" IsReadOnly="{Binding IsNotAdmin}" />
As long as your datacontext is right (which it should be) this should work for you -- it worked in my sample I reconstructed from your code.

Resources