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

Using RawPrinterHelper - How to send the printed paper to default Output Bin/Tray.

$
0
0

As a reference I have used the source from https://support.microsoft.com/kb/322091/en-us?wa=wsignin1.0 for  RawPrinterHelper. This is working great.

Now the problem I am having is, I have two computers and one printer with two printer output Trays or Bins. I configured  Printer Settings in both the computers, so that first computer prints papers to tray1 and second computer prints papers to tray2. These are working as expected when I print local documents. but when I use RawPrinterHelper, all the papers going to tray1. How to handle this issue?

Thank you.


Visual Studio Designer's property setting window

$
0
0

How do I bring up the Visual Studio Designer's property setting window?

I started WPF Application but the design with XAML code is too tedious.

I want to set properties of controls with property window, not code.

I can't see property setting window in my Visual Studio 2010.

It's time for the TechNet Wiki WPF "Great Guru Love-in"! You too can get some loving!

$
0
0

February at TechNet Wiki usually involves a lot of love...

 

We love to read.

We love to learn.

We love our gurus, for they love to give.

 

Computer Geek Love Story Stock Photos

 

We love to make friends and promote great content.

We love to meet the community, and get closer to you.

  

 

We love to interview our winners, and bestow much love and honor upon them.

We love to tell the world of your achievements, and we promote those most active to inner circles!

All you have to do is add an article to TechNet Wiki from your own specialist field. Something that fits into one of the categories listed on the submissions page. Copy in your own blog posts, a forum solution, a white paper, or just something you had to solve for your own day's work today.

Drop us some nifty knowledge, or superb snippets, and become MICROSOFT TECHNOLOGY GURU OF THE MONTH!

This is an official Microsoft TechNet recognition, where people such as yourselves can truly get noticed!

HOW TO WIN

1) Please copy over your Microsoft technical solutions and revelations toTechNet Wiki.

2) Add a link to it on THIS WIKI COMPETITION PAGE (so we know you've contributed)

3) Every month, we will highlight your contributions, and select a "Guru of the Month" in each technology.

If you win, we will sing your praises in blogs and forums, similar to the weekly contributor awards. Once "on our radar" and making your mark, you will probably be interviewed for your greatness, and maybe eventually even invited into other inner TechNet/MSDN circles!

Winning this award in your favoured technology will help us learn the active members in each community.

Feel free to ask any questions below.

More about TechNet Guru Awards

Thanks in advance!
Pete Laker


#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!



#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!

Wiring up an event handler in the XAML editor

$
0
0
How to wire up an event handler in the XAML ceditor?

WPF Richtextbox undo and Redo Operation with syntax hightlight

$
0
0

I am using RichTextBox in one of my WPF Application, users types Text\script in this rich text box, based on the tokens entered by user i apply color, font property to the entered text in the code behind(Syntax highlighting).

I need to perform Undo\Redo Operations, but what i found is the default undo operation works well if i am not changing the color\font properties, but if i change them in my code , it doesn't work.

Is there any issues with Richtextbox ?

issue fixed in WindowsFormsIntegration.dll

$
0
0

Hi,

There's an issue in WindowsFormsIntegration.dll, in class ApplicationInterop, which did not check for the menu state in the right time. The problem exists in version4.0.30319.1, and is fixed in version4.0.30319.17929. How can I know which .Net framework version the fix can be found in? I know it is not in the original .Net 4.5 version, but I need to know which version it is in, and is it available for .Net 4.0 as well.

Yoel

Trouble with ResourceDictionary (Lazy access?)

$
0
0

Hello,

I'm having trouble with my ResourceDictionary. I have a generic.xaml (Build Action=Page)

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:my="clr-namespace:siemens.CSharp.JobManagement"
                    x:Class="IPIPEResourceDictionary"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="/siemens.CSharp;component/themes/buttons.xaml"/><ResourceDictionary Source="/siemens.CSharp;component/themes/colors.xaml"/><ResourceDictionary Source="/siemens.CSharp;component/themes/controls.xaml"/></ResourceDictionary.MergedDictionaries><Color x:Key="TEST">#25254E</Color></ResourceDictionary>

all other ResourceDictionaries are set to Build Action=Content.

The AssemblyInfo.cs has following entry

[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

In one of the resource dictionaries I have a Style

<Style TargetType="{x:Type my:IPIPEStatusSideBarView}"><Setter Property="Height" Value="150"/><Setter Property="Width" Value="350"/><Setter Property="Margin" Value="350,0,0,0"/><Setter Property="Background" Value="#65658E"/>

and I have a control that overrides the style key:

public class IPIPEStatusSideBarView : UserControl
	{
		static IPIPEStatusSideBarView()
		{
			DefaultStyleKeyProperty.OverrideMetadata(typeof(IPIPEStatusSideBarView), new FrameworkPropertyMetadata(typeof(IPIPEStatusSideBarView)));

			//GetDefaultStyle()));
		}

The problem is, that the style never gets applied. I have done some testing a found an interesting thing:

var foo = new Uri("Themes/generic.xaml", UriKind.RelativeOrAbsolute);
			ResourceDictionary dict = new ResourceDictionary();

			dict.BeginInit();
			dict.Source = foo;
			dict.EndInit();


			Style = dict["TEST"] as Style;
			Style = dict[typeof(IPIPEStatusSideBarView)] as Style;
			Style = dict[typeof(IPIPEStatusSideBarView)] as Style;

If I access "TEST" it gives my the value immediately. If I access IPIPEStatusSideBarView I get the value only the second time. If I put it one level up into the main dictionary, it works immediately.

What could be wrong. Why is it loaded in some lazy way?

Thanks

Martin



msedi

GetParentchain not working

$
0
0

Hi!

I am currently working on a software that uses NativeActivities to describe a sequence consisting of different objects, but the GetParentchain class does not seem to work.

Supposing I have the Native Activities : Globe, Continent, Country, City., which are used asModelItems

Globe has a collection of coninents, countries, and cities

Continent cas a collection of countries and cities

and countries has a collection of cities.

I want to Validate the the above rules using a the CheckParent Function example on the msdn Declarative constraints webpage.

After writing the constraint exactly as described above and callling it throuth the following snippet , the constraint does not seem to work

        public static ValidationResults Validate_ModelItem(ModelItem item)
        {
            ValidationResults results = null;
            results = ActivityValidationServices.Validate((NativeActivity)item.GetCurrentValue());
            return results;
        }
Using the same method to get the childrem of each Activity, I get the desired results.

While looking into the variables on real time I notice that the Parent is always null and the actual parent of my object is under the Parent/Parent tag

Any suggestions/ideas?



XBAP HostScript new Window

$
0
0

I'm running into an unusual one that I can't explain and hoping someone can enlighten me.  I've got an XBAP app that interacts with the default.aspx (ASP.NET) page through the BrowserInteropHelper.HostScript object to call a javascript function. This functionality works just fine from the root XBAP application, but our app can open up new WPF Windows.  When trying to access the HostScript from these new Windows we are getting null returned. The parent object is still showing as a web browser, but no joy.

In WPF, when you create a "new Window()" in an XBAP app is this window still running under IE or running as a desktop window?  Is there a way to indicate the new window should run inside an IE iframe or inject the HostScript some how so the window has access to it?

Basically I'm trying to block the IE Help command from opening using JavaScript which works great in the main page but new windows still launch the IE Help as well as my own when using F1.

MVVM and keybinding

$
0
0

I have this form in my MVVM application.

<UserControl xmlns:behaviors="clr-namespace:....">
  ....<UserControl.InputBindings><KeyBinding Key="D1" Command="{Binding KeyCommand}" CommandParameter="{x:Static behaviors:HotKeyCommand.Random}"/></UserControl.InputBindings><Grid>
		...<TextBox Name="N1"  behaviors:TextBoxBehavior.Check="true">
		...</Grid></UserControl>

In "behaviors" setallowed keys input for TextBox:

private static void CheckPreviewKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.NumPad0:
                case Key.NumPad1:
                case Key.NumPad2:
                    break;
                default:
                    e.Handled = true;
                    break;
            }
        }
The problem is when field "N1" is focused, the KeyBinding Key="D1" not working, because CheckPreviewKeyDown handled key D1. I can't removeCheckPreviewKeyDown, because this TextBox must allowed only numbers from numpad keys. How can I solve my problem?

ListViewItem tooltip

$
0
0

Hi!i have a problem.

This code works

<ListView.ItemContainerStyle><Style TargetType="ListViewItem"><Setter Property="ToolTip" Value="someTextHere"/></Style></ListView.ItemContainerStyle>

but this, no.  

<ListView.ItemContainerStyle><Style TargetType="ListViewItem"><Setter Property="ToolTip" Value="{Binding ArticuloSeleccionado.Descripcion"/></Style></ListView.ItemContainerStyle>

ArticuloSeleccionado.Descripcion is string.

How to view all designer resource warnings?

$
0
0
We have hundreds of dialogs in XAML.  
When we make a global resource change, 
it can break the resource links in the XAML.

When we open the XAML view in VisualStudio 2012's designer, 
it show these broken links as resource warnings:

"Warning 43 The resource "XamSliderNumericThumbStyle" could not be resolved."

Is there some way to view all of the designer warnings without manually opening up each dialog?

WPF listbox image binding

$
0
0

Good morning,

I already implemented a application that loads images from a directory to a listbox. All ok but the loading takes about 5 seconds to display around 20-30 images. Is there a way to decrease the time needed for the images to be loaded. Or is it correct to display an loading image in front of the UI so the user knows images are loading? Thank you in advance for the help. Below is my xaml code for the listbox.

<ListBox Name="Images" ListBox.SelectionChanged="lstImagesChange_Click" Grid.Column="1"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" VirtualizingStackPanel.IsVirtualizing="false"
                 VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.IsDeferredScrollingEnabled="True"><ListBox.Resources><Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}"><Style.Triggers><Trigger Property="Orientation" Value="Vertical"><Setter Property="Width" Value="20"/><Setter Property="Height" Value="Auto" /></Trigger></Style.Triggers></Style></ListBox.Resources><ListBox.ItemsPanel><ItemsPanelTemplate><WrapPanel IsItemsHost="True" Orientation="Horizontal" FlowDirection="LeftToRight" /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><Border BorderThickness="2" BorderBrush="#bb62d8" Background="Black" Width="200" Height="200" Margin="5,5,10,5" CornerRadius="10"><Image Source="{Binding Path=Path, Converter={StaticResource UriToBitmapConverter}}" Tag="{Binding ImageID}" /></Border></DataTemplate></ListBox.ItemTemplate></ListBox>

and below is the code loading the images

if (!(images == null))
            {
                Images.ItemsSource = images;
            }

Image processing with decode pixels for TIFF

$
0
0

I have a major issue in my applicaiton due to this issue, Could have been in the base framework for decoding TIF issue.

DECODE PIXEL HEIGHT/WIDTH

"The JPEG and Portable Network Graphics (PNG) codecs natively decode the image to the specified size; other codecs decode the image at its original size and scale the image to the desired size."

in order to display thumbnail in Listbox wrappanel, Image source is been generated with Decodepixels.

This is working neat for JPEGS, where as for TIF it sucks, takes ages for loading.

XAML:

<ListBox Name="scannedimages"  Background="Gray"  SelectionMode="Multiple" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" ItemsSource="{Binding }" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True" Orientation="Horizontal"  ></WrapPanel>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding Path=ImageSource}"></Image>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

Class with ImageSource property, setting the property on binding the path in delegate

private void  setvalues()
        {
           if(FullPath!=null)
           {
               //if (System.IO.Path.GetExtension(FullPath.ToString()).ToUpper() == ".TIF")
               //{

               //    Stream tiff = new System.IO.FileStream(FullPath.ToString(), FileMode.Open, FileAccess.Read, FileShare.Read);
               //    TiffBitmapDecoder tiffdec = new TiffBitmapDecoder(tiff, BitmapCreateOptions.DelayCreation, BitmapCacheOption.OnLoad);
               //    BitmapSource bs = tiffdec.Frames[0];
               //    ImageSource = bs;

                   //JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                   //MemoryStream memoryStream = new MemoryStream();
                   //BitmapImage bImg = new BitmapImage();

               //    encoder.Frames.Add(BitmapFrame.Create(bs));
               //    encoder.Save(memoryStream);

               //    bImg.BeginInit();
               //    bImg.DecodePixelWidth = 100;
               //    bImg.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
               //    bImg.CacheOption = BitmapCacheOption.OnLoad;
               //    bImg.StreamSource = new MemoryStream(memoryStream.ToArray());
               //    bImg.EndInit();

               //    memoryStream.Close();

               //    ImageSource = bImg;
               //    //int width = 100;
               //    //int height = 120;
               //    //var target = new TransformedBitmap( bs,new ScaleTransform(width / bs.Width * 96 / bs.DpiX, height / bs.Height * 96 / bs.DpiY, 0, 0));
               //    //var thumbnail = BitmapFrame.Create(target);
               //    //if (thumbnail.CanFreeze)
               //    //    thumbnail.Freeze();
               //    //return thumbnail;    
               //    //GdPictureImaging img = new GdPictureImaging();
               //    //int imgaid = img.CreateGdPictureImageFromFile(FullPath.ToString());
               //    //int thumbnail = img.CreateThumbnailHQ(imgaid, 100, 120);
               //    //BitmapImage bi = new BitmapImage();
               //    //using (MemoryStream strea = new MemoryStream())
               //    //{
               //    //    img.SaveAsStream(thumbnail, strea, DocumentFormat.DocumentFormatTIFF, 4);
               //    //    strea.Position = 0;
               //    //    bi.BeginInit();
               //    //    bi.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
               //    //    bi.CacheOption = BitmapCacheOption.OnLoad;
               //    //    bi.UriSource = null;
               //    //    bi.StreamSource = strea;
               //    //    bi.EndInit();
               //    //}
               //    //img.ReleaseGdPictureImage(imgaid);
               //    //img.ReleaseGdPictureImage(thumbnail);
               //    //ImageSource = bi;
               //}
               //else
               //{
                   BitmapImage bi = new BitmapImage();
                   bi.BeginInit();
                   bi.DecodePixelWidth = 200;                 
                   bi.CacheOption = BitmapCacheOption.OnDemand;
                   bi.CreateOptions = BitmapCreateOptions.DelayCreation;
                   bi.UriSource = new Uri(FullPath.ToString());
                   bi.EndInit();
                   ImageSource= bi;                  
               //}
           }

        }

CODE BEHIND:

 String folderPath = txtPath.Text.Trim();
            if (Directory.Exists(folderPath))
            {
                DirectoryInfo dirinfo = new DirectoryInfo(folderPath);
                scannedimages.DataContext = pages;
                Task.Run(() =>
                   {
                       foreach (var file in dirinfo.EnumerateFiles())
                       {
                           if (file.Extension.ToUpper().Equals(".TIF") || file.Extension.ToUpper().Equals(".JPG"))
                           {
                               Dispatcher.Invoke((Action)(() =>
                               {
                                   pages.Add(new ImageItem(file.FullName, file.Name));
                               }), DispatcherPriority.Background);

                           }
                       }
                   });
            }

- I have also used URItoBitmap converter for direct binding in XAML code

- You notice- I have used different approaches nothing is working as fast as JPEGs loading. appreciate your help.


Set window min width and min height with SizeToContent

$
0
0

Hi everyone,

I'm currently making an application which contains 1 window and many similar formatted page (width = 500, height = 600).

How can I make the window fit to content and cannot be resized to be smaller but bigger.

Thank you :)


How To Display Hierarchical Data

$
0
0

Hello,

I want to display a expandable list of categories. Each category has a name, an amount, and a list of its styles. Each style also has a name, an amount, and a list of its colors. Each color has a name and an amount. If you click on the expand button of a category, its styles will show. The same thing goes for each styles.

I know a simple TreeView control would do the job if no column headings were needed, but I want to display column headings. The picture below is how I am trying to display the data:

https://social.msdn.microsoft.com/Forums/getfile/609253 (Here is a link to the picture; I can't upload an image because my account is not verified and I can't find how to verify it)

How would I achieve this kind of representation through WPF? I would be also glad if you want to suggest a better way to represent my data, but I do want to have column headings, or something similar (because some styles are named something like '101314' and you would not know it is a style name unless told).

Thank you very much for your help!


Change the image in combobox for selected items ?

$
0
0

 Hello ,

  I have combobox in which i am displaying image and textblock. What i want to do is that change the image when user select particular item.

<ComboBox x:Name="CmbSelect" Foreground="#666" BorderBrush="#C5C5C5" SelectedIndex="0" SelectionChanged="CmbSelect_SelectionChanged" MaxWidth="245"><ComboBox.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Image Width="16" Height="16"><Image.Style><Style TargetType="Image"><Style.Triggers><DataTrigger Binding="{Binding Type}" Value="2"><Setter Property="Source" Value="selfblk.png"></Setter></DataTrigger><DataTrigger Binding="{Binding Type}" Value="1"><Setter Property="Source" Value="calblk.png"></Setter></DataTrigger></Style.Triggers></Style></Image.Style></Image><TextBlock Text="{Binding Name}" MaxWidth="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}},
                                      Path=ActualWidth}"></TextBlock></StackPanel></DataTemplate></ComboBox.ItemTemplate></ComboBox>

I am using two image, which image will be shown on the particular item that is depend on the type. Now i want that when user select any item then image for that item will be changed ( a new image, shape is same but just show that it is selected).

How do i can change image when user select item ..?

C# image placing

$
0
0
What I want to do is have it so when I click somewhere within a specified region it places an image there and I can keep clicking and the same image gets placed leaving the old one too.

Create a Behavior for Calendar in a WPF UserControl to Select and Unselect dates with one click

$
0
0

Hi to everyone,

I am developing an application with a WPF Client. This Client use the MVVM pattern.

In an UserControl the application must show some Calendars, so the user can select one or multiple dates.

For that use, I should implement some behavior that allows the user click once in a date and that date is selected (what already exists in .NET Framework) and with another click in the same date, that date is now unselected.

I've already made some searches and can't find anything useful.

This kind of behavior it is possible to implement in the Calendar Control? How exactly I do this?

Thanks for reading/helping


Rafael Duarte

How to supress script error that arises while using Help.ShowHelp()

$
0
0

Hi,

In order to display Help docs in my product, am using Help.ShowHelp() method in my WPF application  and am successfully getting the help document in a web browser control, but, in few of my test machines am getting a script error along with that. Can anyone please suggest how to suppress that script error.

Regards,

Samjukta

Viewing all 18858 articles
Browse latest View live


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