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

Unhandled Exception: System.NotSupportedException: No information was found about this pixel format.

$
0
0

when I run my program I am facing this exeption, can anyone help me please!

Exception thrown: 'System.NotSupportedException' in PresentationCore.dll
An unhandled exception of type 'System.NotSupportedException' occurred in PresentationCore.dll
No information was found about this pixel format.


Unhandled Exception: System.NotSupportedException: No information was found about this pixel format.
   at System.Windows.Media.PixelFormat.CreatePixelFormatInfo()
   at System.Windows.Media.PixelFormat.get_InternalBitsPerPixel()
   at System.Windows.Media.PixelFormat.get_BitsPerPixel()
   at WpfApp5.MainWindow.<.ctor>g__ToBitmap|0_1(ColorFrame frame) in C:\Users\Student\source\repos\WpfApp5\WpfApp5\MainWindow.xaml.cs:line 96
   at WpfApp5.MainWindow.<.ctor>g__Reader_MultiSourceFrameArrived|0_0(Object sender, MultiSourceFrameArrivedEventArgs e) in C:\Users\Student\source\repos\WpfApp5\WpfApp5\MainWindow.xaml.cs:line 56
   at ContextEventHandler`1.SendOrPostDelegate(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at WpfApp5.App.Main()
The program '[10700] WpfApp5.exe: Program Trace' has exited with code 0 (0x0).
The program '[10700] WpfApp5.exe' has exited with code 0 (0x0).

my complete code is this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
using System.IO;


namespace WpfApp5
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Array pixels;

        public MainWindow()
        {
            InitializeComponent();
        
            KinectSensor _sensor;
            MultiSourceFrameReader _reader;
            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();
            }
            _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color |
                                             FrameSourceTypes.Depth |
                                             FrameSourceTypes.Infrared);
            _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;
            void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
            {
                // Get a reference to the multi-frame
                var reference = e.FrameReference.AcquireFrame();

                // Open color frame
                using (var frame = reference.ColorFrameReference.AcquireFrame())
                {
                    if (frame != null)
                    {

                        // Do something with the frame...
                        camera.Source = ToBitmap(frame);

                    }
                }

                // Open depth frame
                using (var frame2 = reference.DepthFrameReference.AcquireFrame())
                {
                    if (frame2 != null)
                    {
                        // Do something with the frame...
                        camera.Source = ToBitmap2(frame2);
                    }
                }

                // Open infrared frame
                using (var frame1 = reference.InfraredFrameReference.AcquireFrame())
                {
                    if (frame1 != null)
                    {
                        // Do something with the frame...
                        camera.Source = ToBitmap3(frame1);

                    }
                }
            }
            ImageSource ToBitmap(ColorFrame frame)
            {
                int width = frame.FrameDescription.Width;
                int height = frame.FrameDescription.Height;

                byte[] pixels = new byte[width * height * ((PixelFormats.Bgr32.BitsPerPixel + 7) / 8)];

                if (frame.RawColorImageFormat == ColorImageFormat.Bgra)
                {
                    frame.CopyRawFrameDataToArray(pixels);
                }
                else
                {
                    frame.CopyConvertedFrameDataToArray(pixels, ColorImageFormat.Bgra);
                }
                PixelFormat format = new PixelFormat();
                int stride = width * format.BitsPerPixel / 8;

                return BitmapSource.Create(width, height, 96, 96, format, null, pixels, stride);
            }

             ImageSource ToBitmap2(DepthFrame frame)
            {
                int width = frame.FrameDescription.Width;
                int height = frame.FrameDescription.Height;

                ushort minDepth = frame.DepthMinReliableDistance;
                ushort maxDepth = frame.DepthMaxReliableDistance;

                ushort[] depthData = new ushort[width * height];
                byte[] pixelData = new byte[width * height * (PixelFormats.Bgr32.BitsPerPixel + 7) / 8];

                frame.CopyFrameDataToArray(depthData);

                int colorIndex = 0;
                for (int depthIndex = 0; depthIndex < depthData.Length; ++depthIndex)
                {
                    ushort depth = depthData[depthIndex];
                    byte intensity = (byte)(depth >= minDepth && depth <= maxDepth ? depth : 0);

                    pixelData[colorIndex++] = intensity; // Blue
                    pixelData[colorIndex++] = intensity; // Green
                    pixelData[colorIndex++] = intensity; // Red

                    ++colorIndex;
                }
                PixelFormat format = new PixelFormat();
                int stride = width * format.BitsPerPixel / 8;

                return BitmapSource.Create(width, height, 96, 96, format, null, pixelData, stride);
            }
        }
        private ImageSource ToBitmap3(InfraredFrame frame)
        {
            int width = frame.FrameDescription.Width;
            int height = frame.FrameDescription.Height;

            ushort[] infraredData = new ushort[width * height];
            byte[] pixelData = new byte[width * height * (PixelFormats.Bgr32.BitsPerPixel + 7) / 8];

            frame.CopyFrameDataToArray(infraredData);

            int colorIndex = 0;
            for (int infraredIndex = 0; infraredIndex < infraredData.Length; ++infraredIndex)
            {
                ushort ir = infraredData[infraredIndex];
                byte intensity = (byte)(ir >> 8);

                pixelData[colorIndex++] = intensity; // Blue
                pixelData[colorIndex++] = intensity; // Green   
                pixelData[colorIndex++] = intensity; // Red

                ++colorIndex;
            }
            PixelFormat format = new PixelFormat();

            int stride = width * format.BitsPerPixel / 8;

            return BitmapSource.Create(width, height, 96, 96, format, null, pixels, stride);
        }






    }
}


A value of type ItemsControl cannot be added to a collection or dictionary of type TimelineCollection

$
0
0

Hello, my intention is to generate some new buttons after click on already existing button.
I need to create a click trigger after click on that already existing button and then add there ItemsControl container (with button generator).

Here is my whole XAML, i described the crucial code part inside:

<Window x:Class="EnterEventTextBox.DataView"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

xmlns:local="clr-namespace:EnterEventTextBox"

mc:Ignorable="d" Background="Black"

Title="DataView" Height="450" Width="300"

xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

xmlns:cal="http://www.caliburnproject.org" >

<Window.Resources><ItemsPanelTemplate x:Key="ItemsPanelTemplate1"><WrapPanel Orientation="Horizontal" IsItemsHost="True" Background="Turquoise"/></ItemsPanelTemplate><Style x:Key="ItemsControlStyle1" TargetType="{x:Type ItemsControl}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ItemsControl}"><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"><ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible"><ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/></ScrollViewer></Border></ControlTemplate></Setter.Value></Setter></Style></Window.Resources><Grid><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="Auto" /><RowDefinition Height="*" /></Grid.RowDefinitions><ItemsControl ItemsSource="{Binding Shippers}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" Style="{DynamicResource ItemsControlStyle1}"><ItemsControl.ItemTemplate><DataTemplate DataType="{x:Type Button}"><WrapPanel Background="Green" Orientation="Horizontal"><Button Height="50" Width="50" Background="Red" Content="{Binding BtnLabelShipper}" Margin="0,0,5,5"><!--HERE I TRIED TO SET TRIGGER, BUT IT DOES NOT WORK and throws it error wrote in headline--><Button.Triggers><EventTrigger RoutedEvent="Button.Click"><EventTrigger.Actions><BeginStoryboard><Storyboard><!-- THIS I NEED TO EXECUTE WHEN TRIGGER IS FIRED UP><ItemsControl ItemsSource="{Binding Parcels}"><ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type Button}"> <Button Height="50" Width="50" Background="Red" Content="{Binding ParcelNumber}" Margin="0,0,5,5"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> --></Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Button.Triggers></Button></WrapPanel></DataTemplate></ItemsControl.ItemTemplate></ItemsControl></Grid></Window>


Does please somebody have idea how could i execute trigger containing ItemsControl (generating new buttons, but this generatins already works to me).


System.UriFormatException: 'Invalid URI: The hostname could not be parsed.'

$
0
0
After setting SharePoint folder view in explorer, I am trying to play video file in wpf media element, but while setting mediaelement source new Uri getting exception System.UriFormatException: 'Invalid URI: The hostname could not be parsed.'
 Pleas any one help me to resolve this problem.

Thanks&Regards Dhananjay Singh

Problem with updating view (through binding property)

$
0
0

Hello,
my intention is update the whole window whenever Shippers collections or any its member are modified.
Shippers collection and its modifications works fine, but view is not updated in spite of i think i set everything correctly.

Please, can someone see the reason why view is not updated correctly with Shippers collection modifications?

XAML:

<Window x:Class="EnterEventTextBox.DataView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:EnterEventTextBox"
        mc:Ignorable="d" Background="Black"
        Title="DataView" Height="450" Width="300"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:cal="http://www.caliburnproject.org"><Window.Resources><ItemsPanelTemplate x:Key="ItemsPanelTemplate1"><WrapPanel Orientation="Horizontal" IsItemsHost="True" Background="Turquoise"/></ItemsPanelTemplate><Style x:Key="ItemsControlStyle1" TargetType="{x:Type ItemsControl}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type ItemsControl}"><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" 
                                Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"><ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible"><ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/></ScrollViewer></Border></ControlTemplate></Setter.Value></Setter></Style></Window.Resources><Grid><Grid.RowDefinitions><RowDefinition Height="Auto" /><RowDefinition Height="Auto" /><RowDefinition Height="*" /></Grid.RowDefinitions><ItemsControl ItemsSource="{Binding Shippers}" ItemsPanel="{DynamicResource ItemsPanelTemplate1}" Style="{DynamicResource ItemsControlStyle1}"><ItemsControl.ItemTemplate><DataTemplate DataType="{x:Type Button}"><WrapPanel Background="Green" Orientation="Horizontal"><ToggleButton Height="50" Width="50" Background="Red" Content="{Binding BtnLabelShipper}" Margin="0,0,5,5" 
                                cal:Message.Attach="[Event Click] = [Action ShipperIsClicked($dataContext, $this.IsChecked)]">                            </ToggleButton><ItemsControl ItemsSource="{Binding Parcels}"><ItemsControl.ItemTemplate><DataTemplate DataType="{x:Type Button}"><Button Height="50" Width="50" Background="Red" Content="{Binding ParcelNumber}" Margin="0,0,5,5"/></DataTemplate></ItemsControl.ItemTemplate></ItemsControl><!-- --></WrapPanel></DataTemplate></ItemsControl.ItemTemplate></ItemsControl></Grid></Window>


View Model: 

 public partial class DataViewModel : Screen
    {
        public DataViewModel()
        {
            Shippers.Add(new Shipper() { ParcelAmount = 5, ShipperName = "PPLppl", IsUnrolled = true});
            Shippers.Add(new Shipper() { ParcelAmount = 7, ShipperName = "DPDdpd", IsUnrolled = false });
            Shippers.Add(new Shipper() { ParcelAmount = 9, ShipperName = "GEISgeis", IsUnrolled = false });
        }

        public void ShipperIsClicked(Shipper shp, bool isChecked)
        {
            if (shp != null)
            {
                shp.IsUnrolled = isChecked;
                NotifyOfPropertyChange(nameof(Shippers));
            }
        }

        private List<Shipper> shippers = new List<Shipper>();
        public List<Shipper> Shippers
        {
            get { return shippers; }
            set
            {
                shippers = value;
                NotifyOfPropertyChange(() => Shippers);
            }
        }
    }

In WPF textbox onPreviewKeyDown handler is called when third party application is Dictating into the Control

$
0
0

We have a functionality to restrict the user to manually paste the contents in the Text Box which i have handled in OnPreviewKeyDown by checking the CTRL +V  keys for  the Text Box and displaying the message Box that user can not paste the data in the text Box.

But When user is Dictating from third party(Speech to Text ) into the text Box then also OnPreviewKeyDown  handler is getting called and is displayed the Message box that user cannot paste.

Is there a way where we can intercept windows messages for WPF which can determine whether message or Key Down is not from Key Board manually by a user?

Thanks

Munish

How to convert file to bytes, show it in a string, and convert back to file?

$
0
0

Hi  all,

I am not sure  if it is posiible, but at least I amasking  you :-)

I want to do this :

    - convert  file to bytes (for example : *.pdf, *.jpg,  *.png, and other  documents)

    - store  it  in a database

      .......

    - than read it  from  database

    - convert back to  a file and open it

I  am downloading some files and I  dont want to  show them for "other eyes".

Thanks so much!

How to SelectAll in TextBox when TextBox gets focus by mouse click?

$
0
0

If you click into the adress bar of the internet explorer, the adress will get selected. Only the second click sets the caret into the mouse position.

 

I'd like to have this in my TextBox. I tried to override OnGotFocus and call SelectAll(), but this only works if the TextBox gets it focus by keyboard. If the TextBox is clicked by mouse, the text is selected for a split second, then it is deselected again and the caret is set.

 

Thanks,
Sam

Referencing application resources from XAML

$
0
0

Hi All,

One of my older toy development apps (ported from originally Windows Forms to WPF, but I don't think that matters) uses some bitmap resources (originally JPG and PNG files) which have been added to the application's Resources.resx file. While, in most variations I tried, it works fine on the development system,

it reliably keeps failing on anything else, due to exceptions getting thrown because it tries to access the original bitmap files in the project directory of which, usually, not even the drive letter exists on the target machine.

Best Regards

Mrutyunjaya


AccessViolationException When Using CopyMemory on Bitmap->WriteableBitmap

$
0
0

Hello all.

I'm attempting to copy the contents of a Bitmap to a WriteableBitmap.  Unfortunately, I am getting a AccessViolationException when attempting to make the call.  Does anyone have any clues as to what I might be doing wrong?

Here is my code:

WriteableBitmap _writeableBitmap1 = new WriteableBitmap(1920, 1200, 96, 96, PixelFormats.Rgb24, null);privatevoid OnIdeaNotificationReceived(IdeaNotificationMessage m)
{if (m.Notification == Notifications.IdeaFG1OnSnap)
  {
    Bitmap bmp = Bitmap.FromHbitmap(m.Bitmap); // m.Bitmap = hBitmap to memory Bitmap
    BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, 1920, 1200), ImageLockMode.ReadOnly, bmp.PixelFormat);

    _writeableBitmap1.Lock();

    CopyMemory(_writeableBitmap1.BackBuffer, bmpData.Scan0, (_writeableBitmap1.BackBufferStride * 1200));

    _writeableBitmap1.AddDirtyRect(new Int32Rect(0, 0, 1920, 1200));
    _writeableBitmap1.Unlock();

    bmp.UnlockBits(bmpData);
    bmp.Dispose();
  }
}

[DllImport("kernel32.dll", EntryPoint="RtlMoveMemory")]publicstaticexternvoid CopyMemory(IntPtr dest, IntPtr source, int length);

My first guess is that I'm not sure how to calculate the "length" parameter for CopyMemory -- I've tried several variations of heights, widths and strides, but to no avail.

Any help in getting this figured out is greatly appreciated!

Can you help about grid

$
0
0

 dynamicLabel = new Label();

                    dynamicLabel.Content = new TextBlock() { Text = bildir.Bildirim_Mesajı, TextWrapping = TextWrapping.Wrap };
                    dynamicLabel.Width = 242;
                    dynamicLabel.Margin = new Thickness(0, 50 * count++, 0, 0);
                    grid3.Children.Add(dynamicLabel);

ı use this code for grid

but I need to  reload grid and  creat  label again can you help me

WPF - All possible combinations

$
0
0

I need to get all the possible combinations of currencies available to pay a ceiling price, but limiting the amount of coins to 3 units maximum of each value (to pay € 10 it is not valid the use of 10 coins of  € 1)

With the following code I get a combination limited to 3 units per coin, but how can I modify the code to print all the possible combinations?

Thanks in advance.

class Program
   {
   static int amount = 1000;

   static void Main(string[] args)
   {
        Coin[] c = new Coin[] { new Coin(500, 3), new Coin(200, 3), new Coin(100, 3) ,
                                new Coin(50, 3), new Coin(20, 3), new Coin(10, 3),
                                new Coin(5, 3), new Coin(2, 3), new Coin(1, 3)};
        int netAmount = amount;
        for (int i = 0; i < c.Length; i++)
        {
            amount -= c[i].coveredPrice(amount);
        }
        for (int i = 0; i < c.Length; i++)
        {
            Console.WriteLine(c[i].ToString());
        }
        Console.ReadLine();
    }
}

class Coin
{
    private int price;
    private int counted;    
    private int maxNo;

    public Coin(int coinPrice, int coinMaxNo)
    {
        this.price = coinPrice;
        this.maxNo = coinMaxNo;
        this.counted = 0;
    }

    public int coveredPrice(int Price)
    {
        int Num = Price / price;
        if (maxNo == 0)
            return 0;
        if (maxNo != -1)             
            if (Num > this.maxNo - this.counted)
                Num = maxNo;
        this.counted += Num;
        return Num * price;
    }
        public override string ToString()
    {
        return string.Format("{0} x {1} (max {2}) ", this.price.ToString(), this.counted.ToString(), this.maxNo.ToString());
    }
}


Partial struct divided into a .dll and a Local.cs

$
0
0

In WPF with C# i use a partial structure that happened as a parameter in many functions.A part of the structure is in the Comun.cs file that is compiled in Comun.dll and contains general variables to all the programs.

The other part of the partial structure is in a Local.cs file and contains variables specific to each program.I have put this file in App_Data.


When compiling with VS, in the places where i refer to the Local.cs variables, the program tells me that the variables are not recognized.I need to be able to compile the final program so that it recognizes all the variables.I have read that there is a partial interface but I do not know if it is useful for this.

Comun.cs -> Comun.dll

publicpartialstructSt_Gen

{  public int Languaje;

}

 

Local.cs

publicpartialstructSt_Gen

{  public int LocalVariable;

}

Another problem is that I can not find the documentation on the structure of the WPF directories.Ex: App_Data what is it for ...

another problem is that it is difficult to find code from other developers in WPF.¿why?¿Do you know any site besides codeproject?

Thanks

Cannot set JPEG metadata using BitmapMetadata

$
0
0

I am trying to copy all and modify metadata some EXIF fields from a JPEG file using the code below:

public void CopyAndSetMetadata(string sourceFile, string destFile, string sXPTitle, string sXPSubject, string sXPComment, int Width, int Height) { uint paddingAmount = 4096; / using (Stream sourceStream = System.IO.File.Open(sourceFile, FileMode.Open, FileAccess.Read)) { BitmapDecoder sourceDecoder = BitmapDecoder.Create(sourceStream, createOptions, BitmapCacheOption.None); // Check source is has valid frames if (sourceDecoder.Frames[0] != null && sourceDecoder.Frames[0].Metadata != null) { // Get a clone copy of the metadata BitmapMetadata sourceMetadata = sourceDecoder.Frames[0].Metadata.Clone() as BitmapMetadata; // Open the temp file // modify values sourceMetadata.SetQuery("/app1/ifd/PaddingSchema:Padding", paddingAmount); sourceMetadata.SetQuery("/app1/ifd/exif/PaddingSchema:Padding", paddingAmount); sourceMetadata.SetQuery("/xmp/PaddingSchema:Padding", paddingAmount); sourceMetadata.SetQuery("/app1/ifd/exif/{uint=0x100}",Width); // Image Width int 32 sourceMetadata.SetQuery("/app1/ifd/exif/{uint=0x101}", Height); // Image Height int32 sourceMetadata.SetQuery("/app1/ifd/exif/{uint=0x9c9b}", sXPTitle); //XPTitle int 16u sourceMetadata.SetQuery("/app1/ifd/exif/{uint=0x9c9f}", sXPSubject); // XPSubject int 16u sourceMetadata.SetQuery("/app1/ifd/exif/{uint=0x9c9c}", sXPComment); // XPComment int 16u }

... code to set metadata in Destfile } }


However, I get a Type Mismatch error when any of the SetQuery call are made after adding the padding. For the first call to set ImageWidth, i have tried casting the input int parameter Width to uint, long and string and also creating a 2-Byte array. I have alalso tried casting sXPTitle to a Byte array without success. What types does SetQuery expect for its second argument for the didifferent EXIF tags? (I have added the types as shown in the EXIF tags list on the Exiftool web page  https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html as comments.

wpf project with C++/CLI dll System.IO.FileNotFoundException

$
0
0

I create 32bit wpf application with C++/CLI. It runs without problem on my notebook with Windows 7 64b HomeEdition, secondary Windows 7 32b notebook, Windows 10 64b notebook, Windows 8 32b PC. But under Windows 10 64b it stop worked. It throw this:

System.IO.FileNotFoundException: Could not load file or assembly "wrapper.dll" (which is my dll) or one of its dependencies. The specified module could not be found.

Here is full text:

But strange is, my program worked on that system (Windows 10 64b), but today it is not working even older versions of my programs. I have no clue what happens.

What I tried is make for all references inside my wpf project set Copy Local = True. It add lot of dlls inside my release folder, but it doesn't help.

Btw. paths in text I post above, are from my development notebook, but program which throw this error was run under windows 10 64b. 

How to create validation inside a custom datagrid control in wpf

$
0
0

Hai

I want to validate inside my custom datagrid

Something like this

    public class IGrid : DataGrid
    {
        static bool HasError;
    }
    public class DataGridTextcolumn : DataGridTextColumn
    {
        public DataGridTextcolumn()
        {

        }
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = sender as TextBox;
            string newText = textBox.Text;
            if (newText == "xxx")
            {
                IGrid.HasError = true;
            }
            else
            {
                IGrid.HasError = false;
            }
        }
    }
Please help me 

How to validate  the cell using ValidationRule with HasError variable.

Thanks.


programmer


Multilanguage application with text Sql Server Tables in C#

$
0
0
1.- I am looking for some example of multilanguage application in C#. I'm not talking about entering the text of each language by hand.

2.- In WPF I have several ComboBox linked to a table in a Sql Server database. How can I translate the texts retrieved from the database into the active language? I do not want to add in each table a text field for each language.

What is wrong with this ObjectDataProvider declaration?

$
0
0

I was attempting to create a small application to display both System.Windows.Media.Colors and System.Drawing.SystemColors using ObjectDataProvider to wrap the two data sources. Oddly, Colors works but SystemColors does not. This is confusing given that the two are both defined as public static Color xxx {get;}

Here's the XAML.

<Window x:Class="WpfColors.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:d="clr-namespace:System.Drawing;assembly=System.Drawing"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="800" Width="1000"><Window.Resources><ObjectDataProvider 
            ObjectType="{x:Type sys:Type}"
            x:Key="colorsTypeOdp"
            MethodName="GetType" ><ObjectDataProvider.MethodParameters><sys:String>
                    System.Windows.Media.Colors, 
                    PresentationCore</sys:String></ObjectDataProvider.MethodParameters></ObjectDataProvider><ObjectDataProvider 
            ObjectInstance="{StaticResource colorsTypeOdp}" 
            MethodName="GetProperties" 
            x:Key="colorPropertiesOdp"></ObjectDataProvider><ObjectDataProvider 
            ObjectType="{x:Type sys:Type}"
            x:Key="colorsSystem"
            MethodName="GetType" ><ObjectDataProvider.MethodParameters><sys:String>
                    System.Drawing.SystemColors, 
                    System.Drawing</sys:String></ObjectDataProvider.MethodParameters></ObjectDataProvider><ObjectDataProvider 
            ObjectInstance="{StaticResource colorsSystem}" 
            MethodName="GetProperties" 
            x:Key="colorPropertiesSysColors"></ObjectDataProvider></Window.Resources><Grid><Grid.RowDefinitions><RowDefinition /><RowDefinition /></Grid.RowDefinitions><ListBox 
            Grid.Row="0"
            ItemsSource="{Binding Source={StaticResource colorPropertiesOdp}}"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Auto" ><ListBox.ItemsPanel><ItemsPanelTemplate><WrapPanel /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Vertical"><Rectangle Fill="{Binding Path=Name}" Stroke="Black" Margin="4" StrokeThickness="1" Height="50" Width="130"/><Label Content="{Binding Path=Name}" /></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox><ListBox 
            Grid.Row="1"
            ItemsSource="{Binding Source={StaticResource colorPropertiesSysColors}}"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            ScrollViewer.VerticalScrollBarVisibility="Auto" ><ListBox.ItemsPanel><ItemsPanelTemplate><WrapPanel /></ItemsPanelTemplate></ListBox.ItemsPanel><ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Vertical"><Rectangle Fill="{Binding Path=Name}" Stroke="Black" Margin="4" StrokeThickness="1" Height="50" Width="130"/><Label Content="{Binding Path=Name}" /></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Window>

At design time we something like this:

So, Colors is working during design time. Both a color and a name of the color are displayed. However, SystemColors is only making it halfway there. As you can see from the inserted image, the name of the color is available but the Rectangle.Fill is not working. Suggestions?


Richard Lewis Haggard

VS 2017: Settings.Designer.cs Not Regenerating

$
0
0

This is under VS 2017 (commercial version) running under Windows 10 64 bit.

I have a C# WPF project which stores configuration information in app settings. I've previously added a number of fields to Settings.settings, and had the auto-generated Settings.Designer.cs file regenerate to reflect them (this just happened automatically when I built the project).

However, yesterday when I added a new setting to Settings.settings, the auto generation step never took place. Consequently, the new property is not accessible via Settings.Default.NewPropertyName. 

The csproj file contains this element:

  <ItemGroup>
    <None Update="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
    </None>
  </ItemGroup>

This looks odd to me. But I'm no expert on the new csproj format.

How do I configure VS 2017 to do what it used to do, and auto-generate the Settings.Designer.cs file whenever the Settings are changed?

I should also mention that the way the Settings files are displayed in Solution Explorer also looks odd: where Settings.Designer.cs is normally "inside/under" Settings.settings, it displays in parallel with it (i.e., at the same level in the tree view structure).

Change property inside "Tag" property programatically

$
0
0

Hello everyone! I have the following style in my App.xaml:

<!--AboutBackButton--><Style x:Key="AboutBackButton" TargetType="Button"><Setter Property="Background" Value="Transparent"/><Setter Property="BorderBrush" Value="{x:Null}"/><Setter Property="BorderThickness" Value="0"/><Setter Property="Template"><Setter.Value>						                                    <ControlTemplate TargetType="Button">							                <Image Source="{TemplateBinding Tag}"									 
                              VerticalAlignment="Center"									 
                              HorizontalAlignment="Center"									 
                              Height="16"									 
                              Width="16"/>						 </ControlTemplate>					 </Setter.Value></Setter></Style>


Then, I use it in the following way:

<Button x:Name="ButtonAbout"
		Grid.Column="2"
		Style="{StaticResource AboutBackButton}"
		Click="ButtonAbout_Click"><Button.Tag><ImageSource>/Resources/information.png</ImageSource></Button.Tag></Button>


But now I need to change the content of <ImageSource> programatically. Specifically, when the value of a boolean variable changes. How I can do this?

System.Windows.Automation.ElementNotAvailableException in a non automation WPF application running on Windows 10 .net 4.7

$
0
0

Hi,

I'm running a regular WPF application that was compiled using .net 4.6.2. This is not an automation application and has nothing to do with automation at all. This application has been running fine on Windows 7 for years and recently I started running it on Windows 10 version 1703 that comes with .net 4.7 installed. Suddenly couple of weeks ago I got following exception while the software was displaying TreeView control. This happened twice.

I'm trying to find out if this is a Windows 10/.net issue. Any one has any suggestions?


2018-04-10 13:45:45.5416ErrorUnhandled Exception

System.Windows.Automation.ElementNotAvailableException: Element does not exist or it is virtualized; use VirtualizedItem Pattern if it is supported.
   at System.Windows.Automation.Peers.ItemAutomationPeer.ThrowElementNotAvailableException()
   at System.Windows.Automation.Peers.ItemAutomationPeer.GetItemStatusCore()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   at System.Windows.Automation.Peers.AutomationPeer.UpdatePeer(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)

I looked at Windows 10 version 1703 updates and found that there was an update on 
March 13, 2018—KB4088782 (OS Build 15063.966 and 15063.968) and some fixes were done in following areas:

Addresses an issue that causes the touch screen to remain unresponsive. In most cases, using the Power button to turn the screen off and on restores responsiveness. Occasionally, at startup, the touch screen remains unresponsive, and the only recovery mechanism is to restart the phone.

Addresses an issue that delays the on-screen keyboard from reappearing when an external keyboard or scanner is used with device. With this customization, an OEM can define the delay value. For more information, see On-screen keyboard delay.

Addresses issue in which WPF applications that are running on touch or stylus-enabled systems may stop working or stop responding after some time without any touch activity.

UIautomationClient files were affected.

Viewing all 18858 articles
Browse latest View live


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