Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

PresentationFramework Version 4.0.0.0 not found

$
0
0

Windows 7; 64 bit

Visual Studio 2010; working ok until a Blue Screen and computer restart:

Then cannot launch Visual Studio 2010; window saying "PresentationFramework Version 4.0.0.0 not found".

I reinstalled VS 2010 but again it would not launch for the same reason.

Computer seems to be working properly otherwise.

Thanks for suggestions...


sorce code

$
0
0

I have a String = " my name is anurag" i want to break this string into "int length=5"  5 characters and Check that NO Blank space after 5 character and No half word  is Print? suggest me the code

 public void stringsplitter(string itemline , int limit=20)
        {
            try
            {
                itemline = "My Name is Anurag currently i am working with xyz abc pvt Ltd";
                
                int start = 0, end = limit;

                int scale = itemline.Length;
                int part = scale / limit;

                StringBuilder sb = new StringBuilder();
                
                for(int i=0;i<part;i++)
                {
                    string sub=itemline.Substring(start,end);
                    
                     sb.Append(sub);

                    //String result = sb.ToString();
                     
                    MessageBox.Show(sb.ToString());
                     
                }
            }

WPF And VSTO 3.5 Keyboard Focus Question.

$
0
0
Hi All,

I am designing something like this :

A simple form(in wpf), which is set to topmost to true and the form is a non modal window. This form will be called by a VSTO addin in Excel. The XAML is like following :

<Window x:Class="Testing_WPF_Application.Trial"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="Window_Loaded"
    Title="Trial" Height="187" Width="300" Topmost="True"><Grid KeyDown="Grid_KeyDown"><TextBox Height="23" Margin="21,18,28,0" Name="textBox1" VerticalAlignment="Top" KeyDown="Grid_KeyDown" /><TextBox Height="23" Margin="21,50,28,0" Name="textBox2" VerticalAlignment="Top" /><TextBox Height="23" Margin="21,80,28,0" Name="textBox3" VerticalAlignment="Top" /><TextBox Margin="21,110,28,0" Name="textBox4" Height="23" VerticalAlignment="Top" /></Grid></Window>
Now whenever I open this form, since it is top most true, it appears above the Excel Window. however, I am unable to type anything in the textboxes. Whatever I try to type, the keyboard focus directly goes to the active cell in the excel application. Any idea how can I set focus to my textboxes, considering a fact that I need to show the form as non modal only.

Thanks,
Vikas
http://excelnoob.blogspot.com

Change View from ViewModel

$
0
0
Hi,
I have a WPF app (MVVM), which loads a default view on Startup. I have a list box with items and based on the user selection, I need to display a different view for each selection. Something like:
The mainwindow has a grid with listbox in column 0 and Default view in Column1.
Listbox Items: Hotel, Flight, Cruise

if an user clicks Hotel, I'll need to show hotel reservations view in Column1 and hide Default View.
If an user clicks Flight, I'll need to show Flight reservations view in column1 and so on.

Any help will be appreciated.

Thank you

Abhi

Duplicated UserControl TabIndex

$
0
0

Hello everyone,

I have one usercontrol, but I use it 4 times in the same form.

How can i make tabindex in this case?

Regards, ADAE.

EDIT: And I use this usercontrol in others forms too.

FlowDocumentReader ... ReaderScrollViewer

$
0
0

I have a FlowDocumentReader that displays one of those horrid dotted focus rectangles when it gets keyboard focused using tab.

Not the actual control, but something within the control.  I used the snoop tool and it was pointing to ReaderScrollViewer.  I found this thread from 2007 which explains a way of styling it, but I'm not able to get their solution working.  http://social.msdn.microsoft.com/Forums/en-ZA/wpf/thread/2b9b9532-dbfa-4a6a-b2f5-972a04ab39c3

I've tried setting the FocusVisualStyles on just about everything I could think of, but it is not affected...

<Style TargetType="{x:Type ScrollViewer}"><Setter Property="FocusVisualStyle" Value="{x:Null}"/></Style><Style TargetType="{x:Type FlowDocument}"><Setter Property="FocusVisualStyle" Value="{x:Null}"/></Style>

And I am unable to get to it when editing the template.

Can anyone please point me in the right direction?

Thanks a bunch.

~Christine

And here is my simple setup....

<FlowDocumentReader Margin="0,0,0,35" x:Name="flowDocReader" Zoom="50" IsPrintEnabled="True" ViewingMode="Scroll" SelectionBrush="Cyan" MinWidth="600" MaxHeight="600" Width="700" Height="400" IsTabStop="False" Focusable="False" Template="{DynamicResource FlowDocumentReaderControlTemplate1}" FocusVisualStyle="{x:Null}"><FlowDocument x:Name="flowDoc" Focusable="False"  FocusVisualStyle="{x:Null}"><BlockUIContainer x:Name="BlockCont" Focusable="False"  FocusVisualStyle="{x:Null}"><StackPanel x:Name="docPanel" Width="800" Height="1000" Margin="0"  FocusVisualStyle="{x:Null}">						<!--Removed for Troubleshooting--></StackPanel></BlockUIContainer></FlowDocument></FlowDocumentReader>


WPF HwndWrapper COM exception within WCF threads

$
0
0

Hello Folks,

I have a curious issue that is causing me a lot of headaches.  I am creating a rectangle geometry in a server (wcf) thread.  I do this by using the following code:

...

     RectangleGeometry rectangleGeometry = new RectangleGeometry();

      rectangleGeometry.Rect = new System.Windows.Rect(reportLabel.BoundRectOrg.X, reportLabel.BoundRectOrg.Y, reportLabel.BoundRectOrg.Width, reportLabel.BoundRectOrg.Height);
...

If this code runs for a long time along side everything else the server does, I eventually start getting an exception in the constructor:

2013-03-04 16:29:54.7563 FodServer.FodDB.CFodTbl.TraceException Exception occured System.ComponentModel.Win32Exception (0x80004005): The operation completed successfully
   at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
   at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
   at System.Windows.Threading.Dispatcher..ctor()
   at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
   at System.Windows.Media.RectangleGeometry..ctor()
   at ...

Note that this server is a service and has no windows to speak of.  It uses just the system.windows.media geometries and the xaml writer in another section of code.  Nothing is ever rendered to the screen.

This feels like a memory leak but I can't find anything.  Does anybody have any suggestions how to fix this issue?

Canvas Horizontal Line Background is antialiased

$
0
0

Hello together,

I have a Problem using a VisualBrush Tile Background on a Canvas.

I want to draw horizontal and vertical helplines in black Color. But all the time, the lines are antialiased (the vertical is 1 pixel wide but gray and the horizontal line is 2px high and also gray / light gray). If I copy in the Lines to the Childrens of Canvas, it is displayed clear in real black color and only 1 pixel wide.

I have following Source Code.

<Canvas Width="800" Height="400" SnapsToDevicePixels="True"><Canvas.Background><VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute" Viewbox="0,0,20,20" ViewboxUnits="Absolute"><VisualBrush.Visual><Grid><Line X1="0" Y1="0" X2="0" Y2="20" Stroke="Black" StrokeThickness="1" /><Line X1="0" Y1="0" X2="20" Y2="0" Stroke="Black" StrokeThickness="1" /></Grid></VisualBrush.Visual></VisualBrush></Canvas.Background><Canvas.Children><Line X1="50" Y1="50" X2="80" Y2="50" Stroke="Black" StrokeThickness="1" /><Line X1="50" Y1="50" X2="50" Y2="80" Stroke="Black" StrokeThickness="1" /></Canvas.Children></Canvas>

We use .NET 4.0.

Can you please help me how to solve this problem to get really black and clear lines in Background?

Thank you.

Kind regards
Stefan


introducir una ventana dentro de otra ventana

$
0
0

bueno, acabo de pasar de windows forms con c# a WPF. hasta ahora no he tenido problemas, actualmente estoy haciendo una aplicacion del tipo Windows el cual funciona bien, pero quisiera saber como cargar el contenido un elemento Windows dentro de la ventana principal por asi decirlo y estar cambiando de ventanas. si me pudieran ayudar.
el condigo que tengo es el clasico.

primer_set.Visibility = System.Windows.Visibility.Hidden;
                    set primerset = new set(izquierda.Content.ToString(),derecha.Content.ToString(),sirve);

                    this.Visibility = System.Windows.Visibility.Hidden;
                    primerset.ShowDialog();
                    this.Visibility = System.Windows.Visibility.Visible;

como dije, quisiera que en ves de abrir una nueva ventana se cargara dentro de la ya existente

Custom ItemsControl: Validating the ItemsControl's ItemsPanel and ItemsSource?

$
0
0

Hi,

I created my own custom panel and i am creating a custom itemscontrol which only can use the custom panel. How should i override the metadata for the ItemsPanelProperty to make sure that the panel is my custom panel?

Same goes for the ItemsSource, how should i make sure the ItemsSource is an IEnumerable<MyCustomClass>?

White flash on window load

$
0
0
Is there a way to get rid of white flash that is shown before window is loaded by window.show() method. I have a bit of calculation in Window_Loaded event ?

Rotation of whole screen in Microsoft Surface 2.0

$
0
0
Hello I want to rotate the whole screen of surface application such that when the user move its finger to top direction or bottom direction the whole screen should rotate in that direction accordingly.

WPF TextBox.Text VS Variable

$
0
0

There is a textbox myTextBox in my WPF application.

The myTextBox.Text value is used by a button function for a few times.

I would like to know is there any difference in PERFORMANCE and MEMORY USAGE for the following cases:

a) Directly use myTextBox.Text for a few times

Call functionA(myTextBox.Text);

Call functionB(myTextBox.Text);

or

b) Declare a variable first then use it in the latter part

string str = myTextBox.Text;

Call functionA(str);

Call functionB(str);

Thanks.

It would be great if any reference link or further reading for such information.

Using Custom RoutedUICommand in xaml throws exception

$
0
0

I have followed this article and some others to create a Custom RoutedUICommand.
I am using Infragistics Ribbon, but I dont think the problem comes from there.

<igRibbon:XamRibbonWindow x:Class="MyRibbonWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:igRibbon="http://infragistics.com/Ribbon"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:MyNamespaceTag="clr-namespace:MyNamespace"
    xmlns:igWPF="http://schemas.infragistics.com/xaml/wpf" mc:Ignorable="d" 
    WindowState="Maximized">    <igRibbon:XamRibbonWindow.Resources><!-- Some DataTempaltes here --></igRibbon:XamRibbonWindow.Resources><igRibbon:RibbonWindowContentHost x:Name="ribbonWindowContentHost" ><igRibbon:RibbonWindowContentHost.Ribbon><igRibbon:XamRibbon x:Name="xamRibbon" Theme="[current]"><igRibbon:XamRibbon.ApplicationMenu><igRibbon:ApplicationMenu><igRibbon:ApplicationMenu.FooterToolbar><igRibbon:ApplicationMenuFooterToolbar><igRibbon:ButtonTool Name="appMenuOptions" Caption="Opt_ions"/></igRibbon:ApplicationMenuFooterToolbar></igRibbon:ApplicationMenu.FooterToolbar></igRibbon:ApplicationMenu></igRibbon:XamRibbon.ApplicationMenu></igRibbon:XamRibbon></igRibbon:RibbonWindowContentHost.Ribbon>       <ContentControl Content="{Binding MyContent}"
          ContentTemplateSelector="{StaticResource myContentTemplateSelector}" />       </igRibbon:RibbonWindowContentHost>    </igRibbon:XamRibbonWindow>

We needed to change the look and feel of the Infragistics Ribbon, and a team member from Infragistics comunity suggested an Style to be added. The problem is that when we added it to the Resources section of the Ribbon, it didn't work.
So we were forced to do the following:

var resourceDictionary = new ResourceDictionary();
    resourceDictionary.Source = new Uri(
        @"/MyNamespace;component/Resources/RibbonResources.xaml", 
        UriKind.RelativeOrAbsolute);
    xamRibbon.Resources.MergedDictionaries.Add(resourceDictionary);

This applies correctly the styles in the ribbon, but in that RibbonResources.xaml we have a button:

<Button Name="myButton" 
        Command="MyNamespaceTag:MyCommands.MyCommand" 
        Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"><Image Source="MyImage.png" Width="16" Height="16" /></Button>

The MyCommand and MyCommands class, have been created exactly as the article i mentioned.
But when I run the application I get the following error:

•XamlParseException: Failed to create a 'Command' from the text
MyNamespace:MyCommands.MyCommand'
       InnerException: Type reference
       cannot find type named '{clr-namespace:MyNamespace}MyCommands'.

If I use the command like this instead:

Command="{x:Static MyNamespaceTag:MyCommands.MyCommand}"I get the following exception:

•XamlParseException: Provide value on
'System.Windows.Markup.StaticExtension' threw an exception.
       InnerException: Type reference cannot find type named
       '{clr-namespace:MyNamespaces}MyCommands'.

In the code-behind we are binding the command like this:

CommandBindings.Add(
        new CommandBinding(
            MyCommands.MyCommand, 
            Show, 
            CanShow));

If we put the button directly where we have the XamRibbonWindow, it works fine.

I am still pretty new with WPF, and I can't figure out what I am doing wrong.

AppCan (includes Prism + more) = Better apps/compositing

$
0
0

Announcing new Open source project on codeplex -

AppCan Codeplex Site

Project Description
AppCan enhances Prism by offering more of a thin application framework and compositing capability around what prism provides.  i.e. Document management (i.e. Models/Containers), Menu/toolbar merging, local region managers, standardized regions, view model extensions and more.

Intended Audience

Software Developers building WPF applications.  AppCan adds additional patterns and practices to Prism to offer a more complete compositing/application framework experience.

Other projects includes

Current version of AppCan includes Prism 4.1, and Log4Net

Learn about AppCan classes/functionality


Goals:

  • More complete compositing/application framework, providing good base functionalities for standard application implementations
  • Support better decoupling between classes i.e. views, viewmodels, etc. (i.e. not requiring specific interfaces/types to be known for all classes/view models used)
  • Support better/easier compositing of modules, classes, views, etc.
  • Provide better encapsulation by localizing regions and services/classes to avoid single global repositories
  • Keep in mind garbage collections to try to reduce the need for garbage collections during runtime


AppCan allows developers to put the pieces of Prism together more cleanly/and easily. It allows for logically associating ViewContainers, Views and View models.

AppCan enhances prism by supporting Contexts that wrap together Windows, their views, their region managers and their view models, along with any other classes you might need.

AppCan reduces the need for specific dependencies/types, allowing modules and code to register requests for generic Views, ViewContainer and ViewModel interfaces without needing to know specific types from other modules. By separating Views and View Models into their own contexts the specific types no longer matter and generic interfaces can be used for the View and the View model.
AppCan solves the problem of supporting locally scoped region managers, by implementing a pattern/framework to support it.

AppCan allows for easily enhancing/replacing windows, views, viewmodels, etc. Allowing for extending/enhancing existing windows/views more easily.

AppCan view model extensions allow adding objects to be referenced by the existing view model so you can add functionality to views without needing to rewrite the existing view model class, just extend it by adding your own extension object you can bind to from the view.

AppCan allows you to Merge menu's from modules into your main shell!

Model support: You’ve heard MVVM but implementations for Model’s has been mostly left to be individually recreated for every application. AppCan supports a simple framework to build upon.


Included in the current version is:
AppCan
Prism 4.1
Log4net


Learn about AppCan classes/functionality



DocumentViewer with XPS - large memory consumption on first copy operation?

$
0
0

We are implementing e-book reader based on documentviewer control. Each e-book is exe file with xps as embedded resource. XPS are decrypted and displayed by documentviewer control, hosted on plain C# form from System.Windows.Forms.

For some reason when user performs first copy (couple of paragraphs, not even the whole page) everything hangs for ca 60seconds, and additional 200-300MB is allocated. This memory is never released, and next copy operations work without additional time&memory overheads.

We have our own wndproc, which should handle clipboard operations, but delay and memory are wasted before wndproc on main form is called.

Anyone got any solution how to decrease time+memory consumption by documentviewer?

Style set in Application level affect the host [ActiveX client written in WPF]

$
0
0

Hi,

My application A is written in WPF, I have some global styles that I set in the Application level [App.xaml]. Example below:

<Style TargetType="{x:Type ComboBox}">[change background color]</Style>

I created a host, which is WPF as well, to host A as an activeX. Since I set the style in the Application level, my Host get styled as well.

I've been researching for few days on how to prevent this,

1. Include 'key' in the style, all the control in A will need to use the key.

2. In the host, App.xaml, set the global style to be empty, so that it will overwrite the global style.

<Style TargetType="{x:Type ComboBox}"></Style>

My problem: I can't control the host to overwrite the global style. As my application is quite huge, it is not practical for me to add in the key for all the controls that we did not specify a style using key.

Question: Are there any other way to prevent the activeX client WPF global style to affect the host? 

Or is there any way for me to apply the global style within my application only? 

Any help is appreciated.

ComboBoxItem with delete button not deleting an Item

$
0
0

Hi,

I have a ComboBox, If I add a Item in a Combobox,It should get added in a Combobox as comboboxItem.

As Item I am providing a Template as Textblock and a Delete Button,by clicking on Delete button in ComboboxItems,It should delete

mouse Hover item.How I do Deleting part?

Regards,

Rosy D

<ComboBox Name="cmb" Margin="0,0,0,0" Grid.Row="0" Grid.Column="0"  HorizontalAlignment="Left" Height="20" 
                               SelectedItem="{Binding SelectedLangItem,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                IsSynchronizedWithCurrentItem="True" 
                                IsEditable="True" VerticalAlignment="Top" Width="{Binding Path=Width.AdjustedValue, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"  
                                ItemsSource="{Binding Path=FreeTextList,Mode=OneWay,NotifyOnSourceUpdated=True}"  ><ComboBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><TextBlock DataContext="{Binding}" Text="{Binding CurrentLanguageContent}" Width="{Binding Path=Width.AdjustedValue, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"  
                                           TextWrapping="Wrap" HorizontalAlignment="Left"  /><Button  x:Name="btnDel" Style="{StaticResource RibbonIconButtonStyle}"  HorizontalAlignment="Right"
                                            common:CreateCommandBinding.Command="{Binding Path=DeleteLangTextCmd}"
                                             PreviewMouseLeftButtonDown="btnDel_PreviewMouseLeftButtonDown"
                                             Width="20" Height="20"  ><Button.Content><Rectangle Fill="{Binding Path=Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button} }"
                                                    OpacityMask="{DynamicResource DeleteIcon}"  Margin="0,0,5,0" Width="Auto" Height="Auto" 
                                          HorizontalAlignment="Stretch"   /></Button.Content></Button></StackPanel></DataTemplate></ComboBox.ItemTemplate></ComboBox>

wpf DataGrid

$
0
0

if you double click the new empty row of datagrid and double click the other row of datagrid, the datagrid will auto add new empty row.

is it the bug of datagrid?  if not, but what is the use of it ?


Expander out the side of window

$
0
0

I would like to create an expander that goes outside the current window.  Kind of like a subwindow that jets out of the side.  When I click it, I want it to expand to the "GRAY" portion below.



Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>