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

WPF: How to animate Blur Effect RadiusProperty in C# code?

$
0
0

Question: How to animate Blur Effect RadiusProperty in C# code?

Notes:

1. I can animate Line position in the same way, but it doesn't work with Blur Effect RadiusProperty.

2. I have XAML code and it works.

3. It must be done on C# code.

4. Duration set to 0 is no problem, it works well with Line position (it happens fast and i see the result immediately).

Code (doesn't work):

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += MainWindow_Loaded;
        }

        BlurEffect blur;

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Canvas canvas = new Canvas();
            canvas.Background = Brushes.Black;
            this.Content = canvas;

            blur = new BlurEffect();
            blur.Radius = 20;

            Line line = new Line();
            line.Stroke = Brushes.White;
            line.X1 = 0;
            line.Y1 = 0;
            line.X2 = 100;
            line.Y2 = 100;
            line.Effect = blur;

            canvas.Children.Add(line);

            Animation();
        }

        private void Animation()
        {
            DoubleAnimation da = new DoubleAnimation();
            da.To = 0;
            da.Duration = TimeSpan.FromSeconds(0);

            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(da, blur);
            Storyboard.SetTargetProperty(da, new PropertyPath(BlurEffect.RadiusProperty));
            sb.Children.Add(da);
            sb.Begin(); // Doesn't animate.
        }
    }

Hide Toolbar overflow arrow

$
0
0

Is there a simple way to hide the toolbar control's overflow arrow?

Another weird behavior is that it doesn't respect the background transparency. So if you have a toolbar with transparent background, this overflow arrow will not be transparent.

Convert KeyPressed to character?

$
0
0

I have a KeyDown event and I simply want to get the character the user typed (as a string actually)...

 

private

void OnMyTextBoxKeyDown( object sender, KeyEventArgs e )

{

...

string char = Convert.ToChar( e.Key )... ???

}

Custom FrameworkElement visual states

$
0
0

Ideas on exception? Why do I get this, cannot find the source of it & cannot reproduce in "simple" project.

System.Windows.Markup.XamlParseException: Get property 'System.Windows.VisualStateGroup.States' threw an exception. ---> System.Reflection.TargetException: Object does not match target type. at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target) at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, OThe thread 0x64a4 has exited with code 259 (0x103).

  at System.Xaml.Schema.SafeReflectionInvoker.InvokeMethodCritical(MethodInfo method, Object instance, Object[] args)
   at System.Xaml.Schema.SafeReflectionInvoker.InvokeMethod(MethodInfo method, Object instance, Object[] args)
   at System.Xaml.Schema.XamlMemberInvoker.GetValueSafeCritical(Object instance)
   at System.Xaml.Schema.XamlMemberInvoker.GetValue(Object instance)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.GetValue(XamlMember member, Object obj)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.GetValue(Object obj, XamlMember property, Boolean failIfWriteOnly)
   --- ---
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
   atSystem.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 a

When attempting to create custom visual states for a cell template e.g.

                <DataGridTemplateColumn Header="MyHeader">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid x:Name="MyCell">

<VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="MyGroups"><VisualState x:Name="Group1"><Storyboard /></VisualState><VisualState x:Name="Group2" /><VisualState x:Name="Group3" /></VisualStateGroup></VisualStateManager.VisualStateGroups>

                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

Other background:

I am also using WPFToolkit but avoid collision by specifing sw where needed (yes, tried specifing with vsm: incase it would be the confusion with toolkit visualstatemanager but its not the cause).

xmlns:vsm ="clr-namespace:System.Windows;assembly=PresentationFramework"

xmlns:sw ="clr-namespace:System.Windows;assembly=WPFToolkit"

WPF MediaElement mess up when play loop.

$
0
0

WPF MediaElement

As the sample, When my application is full screen, and then active another app, when I back to the sample application, the video mess up!

Application crashes only on System Reboot/Shutdown

$
0
0

Hi,

i have an application in C#/WPF that loads it's modules in separate AppDomains using Marshaling. Each module has it's own window, but it inherits a WindowBase with an application wide unique theme. Now i've put the usual Close/Minimize/Maximize buttons in this theme and it's wired up correctly so that all classes call their clean up methods. In a normal usage, clicking on the "X" in the window will properly close the window and :

 - If it's a module window, it will clean all it's unmanaged resources

 - If it's the main  window, it will call close on all modules, then clean up it's own unmanaged resources

It's all working well without a hitch, but then when i Rebooted the system, the application crashed. It does so every time the system is shutdown or rebooted.

Is there a way to debug this? Or are there some possible reasons as to why the crash is happening?


WPF: How to set Storyboard.SetTargetProperty by reference for BlurEffect in C# or enable IntelliSense?

$
0
0

Situation: Iset Storyboard.SetTargetProperty for BlurEffect radius by string.

Problem: IntelliSense doesn't apply to string.

Questions:

1. How to set it by reference easy without complexity just like i do with Line position setting it by reference.

2. How to enable IntelliSense?

3. How can i know what property path to use (get a list of them, msdn link describing all of them)?

Note: It must be done in C#, not XAML.

Code:

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += MainWindow_Loaded;
        }

        Line line;
        BlurEffect blur;

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Canvas canvas = new Canvas();
            canvas.Background = Brushes.Black;
            this.Content = canvas;

            blur = new BlurEffect();
            blur.Radius = 20;

            line = new Line();
            line.Stroke = Brushes.White;
            line.X1 = 0;
            line.Y1 = 0;
            line.X2 = 100;
            line.Y2 = 100;
            line.Effect = blur;

            canvas.Children.Add(line);

            Animation();
        }

        private void Animation()
        {
            DoubleAnimation da = new DoubleAnimation();
            da.To = 0;
            da.Duration = TimeSpan.FromSeconds(1);

            Storyboard sb = new Storyboard();
            Storyboard.SetTarget(da, line);
            Storyboard.SetTargetProperty(da, new PropertyPath("Effect.Radius")); // How to set it by reference or enable Intellisense?
            sb.Children.Add(da);
            sb.Begin();
        }
    }




Translation Windows Form to WPF

$
0
0

Hi ,

OS : Windows 10 Family

Visual Studio Community 2015

Language : VC#/VB 2015 ( I prefer VC# but I have often posted translation in VB when the OP is prefering VB to VC# )

I would translate this code written for Windows Forms to WPF as I am beginning to study WPF which seems to be an available replacement solution to the System.Windows.Forms I have begun to use in 2003 in replacement of the MFC of C++ ( used from 1995 )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Test_WinForms_VCS2013
{
    static class Program
     {
          /// <summary>
          /// The main entry point for the application.
          /// </summary>
          [STAThread]
          static void Main()
          {
               if ( CommonCls.AppInit("en-US"the method AppInit) )
               {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new MainForm());
               }
               else
               {
                    MessageBox.Show(CommonCls.ErrorMessage,CommonCls.ShortMessage);
               }
               if ( !CommonCls.AppClose() )
               {
                    MessageBox.Show(CommonCls.ErrorMessage , CommonCls.ShortMessage);
               }
        }
    }
}

The CommonCls class is a static ( shared in VB  ) class providing properties and methods which are useful for me. For example , the AppInit method getting information about the system or the current application and creating an application log file in which I am writing errors or information about of the execution of the execution. The AppClose method writes information about the execution and process times of the curently executing application.

As I am a beginner in WPF , I don't know where I have to put this code in the Main method.

Same question about the CommonCls.AppClose method which has to be called when the currently executing application is closing.

I would appreciate any help as I  don't know how to solve this problem as there is a big warning in the auto_generated code of the Main method

//------------------------------------------------------------------------------// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#pragma checksum "..\..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "D2D07AF1F48529C88EB1DD5D7EBAAC59"
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using WPF_VCS2015_SMO2014_Test_ManagedComputerClass;


namespace WPF_VCS2015_SMO2014_Test_ManagedComputerClass {


    /// <summary>
    /// App
    /// </summary>
    public partial class App : System.Windows.Application {

        /// <summary>
        /// InitializeComponent
        /// </summary>
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
        public void InitializeComponent() {

            #line 5 "..\..\..\App.xaml"
            this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);

            #line default
            #line hidden
        }

        /// <summary>
        /// Application Entry Point.
        /// </summary>
        [System.STAThreadAttribute()]
        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
        public static void Main() {
            WPF_VCS2015_SMO2014_Test_ManagedComputerClass.App app = new WPF_VCS2015_SMO2014_Test_ManagedComputerClass.App();
            app.InitializeComponent();
            app.Run();
        }
    }
}

Thanks beforehand.

 


Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


second window in own thread crashes whole app

$
0
0

Hallo,

I have the following problem. I have a window in my project which needs to start in its own separate thread. This goes ok. However when i have an error in the second window the whole app crashes including my MainWindow. Of course i could try to catch all posible errors but you never know. How can i prevent an error in the second window from crashing my whole application?

This is how i start my second window in its own thread.

        private Thread _thread;
        HTMainWindow _HTTempWindow;
        private void StartHistoryTrend()
        {
            /////////////////////////////////////////////////

            if (_thread == null || !_thread.IsAlive || _thread.ThreadState == System.Threading.ThreadState.Stopped)
            {
                // Create a thread
                Thread newWindowThread = new Thread(new ThreadStart(() =>
                {
                    // Create our context, and install it:
                    SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));

                    _HTTempWindow = new HTMainWindow(MainWindowStaticHelper.CurrentProjectBasePath);
                    // When the window closes, shut down the dispatcher
                    _HTTempWindow.Closed += (s, e) =>
                       Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                    _HTTempWindow.Show();
                    // Start the Dispatcher Processing
                    System.Windows.Threading.Dispatcher.Run();
                }));

                // Set the apartment state
                newWindowThread.SetApartmentState(ApartmentState.STA);
                // Make the thread a background thread
                newWindowThread.IsBackground = true;
                // Start the thread
                newWindowThread.Start();
                _thread = newWindowThread;
                /////////////////////////////////////////////////

            }
            else
            {
                _HTTempWindow.OnSetVisibility();
            }

        }


Jc

.NET 4.5 RibbonControl: Empty bar on top of Ribbon when not using RibbonWindow?

$
0
0

Hi!

my team and I are currently working on an application that is supposed to use a Ribbon as a menu. As we are trying to override the default style of the window we noticed that the Ribbon has some kind of a bar ontop of it which takes up space and holds the window's title. We then tried to use a regular Window instead of the RibbonWindow but it is still taking up some useless space by showing an empty bar now. We only want to use the basic functionality of the Ribbon no attaching of functions to the Titlebar of the window or something like that.

Does anybody know how this bar is called and if there is a way to get rid of it?

Regards

Ralf

Problems with WPF Ribbon control in .NET 4.5

$
0
0

I'm having massive issues with the WPF ribbon. Here's a bit of Ribbon code. (I'm usingSystem.Windows.Controls.Ribbon), all of this inside a RibbonWindow on .NET 4.5/VS2012.

<Ribbon VerticalAlignment="Top" Height="Auto" HorizontalAlignment="Stretch"><RibbonTab Header="Home" Height="Auto" VerticalAlignment="Top"><RibbonGroup Header="Save/Load" Height="Auto" Margin="0" VerticalAlignment="Top" Width="Auto"><Grid HorizontalAlignment="Stretch"><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="Auto" /></Grid.ColumnDefinitions><Button x:Name="cmdLoadImage" Click="cmdLoadImage_Click" Margin="10,10,10,10" Grid.Column="0"><Image Source="Images\load-icon.png" /></Button></RibbonGroup></RibbonTab></Ribbon>

Point 1-2 are bugs.

  1. I can't change the height of the Ribbon, despite changing the VerticalAlignment properties of the RibbonTab and RibbonGroup toStretch. The visual height remains the same.
  2. Changing the Button to a RibbonButton vanishes the image inside it, while keeping it atButton has visual repercussions.
  3. How do I make the Ribbon span the window as in MS Office? The ApplicationMenu going to the top, and so on?

EDIT: A free, alternate ribbon control library for WPF will be appreciated. I want to use it commercially.


Hameer Abbasi

BindingExpression collection in BindingGroup is always empty

$
0
0

I'm trying to implement save functionality for the page. For this, I have two way binding on my controls with UpdateSourceTrigger value set as "Explicit". I'm using the explicit option so that my bound view model property doesn't change immediately upon making change and it only change when I press "Save" button. If I press, "Cancel" button, I will leave my page without updating the bindings so that my original values don't change.

I want to make use of BindingGroup and want to update bindings on all my controls in one go. I have code implement as shown below but here the problem is, I don't get any value in BindingExpression collection of BindingGroup and it always remains empty. I understand, I should get all the bindings for which matching binding group name is set should be part of BindingGroup.BindingExpressions collection. Because of this even if I call "BindingGroup.UpdateSources()", I don't get new values updated to my view model.

Can you pls go through following code n suggest what is wrong (i.e. either my understanding about BindingGroup or my implementation)

XAML code

<Window x:Class="WpfApplication1.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="300" Width="300"><StackPanel><StackPanel.BindingGroup><BindingGroup x:Name="Group"/></StackPanel.BindingGroup><TextBox Text="{Binding P1, Mode=TwoWay, BindingGroupName=Group, UpdateSourceTrigger=Explicit, ValidatesOnDataErrors=True}"/><TextBox Text="{Binding P2, Mode=TwoWay, BindingGroupName=Group, UpdateSourceTrigger=Explicit, ValidatesOnDataErrors=True}"/><TextBox Text="{Binding P3, Mode=TwoWay, BindingGroupName=Group, UpdateSourceTrigger=Explicit, ValidatesOnDataErrors=True}"/><Button Content="Update Values" Click="Button_Click"/></StackPanel></Window>

Code behind

using System;
using System.Collections.Generic;
using System.ComponentModel;
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.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window2.xaml
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            this.DataContext = new VM();
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Group.UpdateSources();
        }
    }

    public class VM : INotifyPropertyChanged
    {
        private string _p1, _p2, _p3;

        public string P1
        {
            get
            {
                return _p1;
            }
            set
            {
                _p1 = value;
                NotifyPropertyChanged("P1");
            }
        }

        public string P2
        {
            get
            {
                return _p2;
            }
            set
            {
                _p2 = value;
                NotifyPropertyChanged("P2");
            }
        }

        public string P3
        {
            get
            {
                return _p3;
            }
            set
            {
                _p3 = value;
                NotifyPropertyChanged("P3");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string name)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }
}

I am aware that I can get the BindingExpression for each individual control and call updatesource to update viewmodel property but it is very tedious way and everytime I add new field, I will have to add new update call as well. I want some generic implementation and I thought BindingGroup can help.

Thanks,


Krunal C

Using User Controls with MVVM pattern

$
0
0

I want to create user controls that plug into View Models.  They currently do not work because (from what I can figure) is that I am not registering the user control to interact with the parent window for the purposes of MVVM.  

How do I register the User Control into the parent window?

WPF Usercontrol XAML common namespace seperate in another xaml like base

$
0
0

In my WPF application all UI containing the same namespace like

<UserControl x:Class="VSSPORT.ACHolderView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Custom="http://schemas.devexpress.com/winfx/2008/xaml/editors/internal"
             xmlns:apr="clr-namespace:AproAutoComplete;assembly=AproControls"
             xmlns:aproControls="clr-namespace:AproControls;assembly=AproControls"
             xmlns:citystatezip="clr-namespace:AproCityStateZipControl;assembly=AproControls"
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:ek="clr-namespace:VSSPORT"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:local="clr-namespace:VSSPORT"
             xmlns:toolbar="clr-namespace:AprosoftToolBar;assembly=AproControls"

Is it possible that i will use a base xaml which will contain all the common namespace and i will use the base xaml in my every wpf usercontrol UI.


Regards atik sarker


Visual Studio 2015 and PRISM compatibility issue

$
0
0

I downloaded the Microsoft Patterns & Practices sample code for Prism Interactivity.

http://www.microsoft.com/en-us/download/details.aspx?id=42537

If I open this project with Visual Studio 2013, and open up the InteractionRequestView.xaml, everything looks fine.  I can see the UserControl in the designer and no errors.  Also I can build and run without a problem.

If I open this project with Visual Studio 2015, and open up the InteractionRequestView.xaml, I cannot see the design-time of the UserControl.  It states Invalid Markup.  If I look at the errors panel, it shows that on the line

<prism:InteractionRequestTrigger SourceObject="{Binding RequestShowConfiguration, Mode=OneWay}">

has an error that states:  "The local property 'Actions' can only be applied to types that are derived from 'TriggerBase'.  The code still compiles and runs correctly.  This would not be much of an issue as it would an annoyance, if it were not for the fact that the designer does not load because of 'invalid markup'.

Does anyone know how to fix this issue?  Is anyone else having the issue?  The code is obviously correct, since it runs.  All I can determine is there is some issue in the IDE.

Thanks,

Michael


HOw to make a checkBox readonly in WPF??

$
0
0

HOw to make a checkBox readonly in WPF??

 

Thanks

DNB1

[UWP][WPF][C#] Trying to use CryptographicBuffer in WPF application

$
0
0

Ok, I know this question is going to be a bit weird... but here goes:

I have an existing WPF application which uses AES encryption. I am currently developing a UWP version for Windows 10 and also Windows Phone. While developing the UWP app, I made some improvements to the encryption process and I actually prefer the CryptographicBuffer over the .NET version.

Now I have a problem...

I'd like for users of the WPF application to upgrade their documents to the newer encryption, so that these documents can be shared between the Desktop version, and the UWP app version.

I created a class library that contains the encryption code, and it is referenced by the UWP app. But I tried in many ways to get my WPF app to reference the same library... to no avail. Which I understand.

So, is there ANY possible way to somehow get my WPF application to use the CryptographicBuffer? If there is no conceivable way to accomplish this, I would somehow need to get the same encryption in WPF using the .NET classes. One problem I know I am facing is I'm not sure what the equivalent process would be to derive the encryption key.

In my UWP app, I am using the Pbkdf2Sha512 key derivation provider, but know of no comparable provider in .NET for my WPF app.

Here is the UWP app KeyDerivation code:

/// <summary>
        /// iteration count for deriving key material
        /// </summary>
        private const int KEY_DERIVATION_ITERATION = 147592;

        /// <summary>
        /// Gets the encryption key material for a password
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        private static IBuffer GetEncryptionKeyMaterial(string password, IBuffer saltBuffer)
        {
            //get a password buffer
            var pwBuffer = CryptographicBuffer.ConvertStringToBinary(password, BinaryStringEncoding.Utf8);

            //create provider
            var keyDerivationProvider = KeyDerivationAlgorithmProvider.OpenAlgorithm(KeyDerivationAlgorithmNames.Pbkdf2Sha512);
            //create a key based on original key and derivation parmaters
            var keyOriginal = keyDerivationProvider.CreateKey(pwBuffer);

            //using salt and specified iterations
            var pbkdf2Parms = KeyDerivationParameters.BuildForPbkdf2(saltBuffer, KEY_DERIVATION_ITERATION);
            //derive new key
            var keyMaterial = CryptographicEngine.DeriveKeyMaterial(keyOriginal, pbkdf2Parms, 32);

            //return encryption key
            return keyMaterial;
        }

And the revevant encryption code:

//get key from our random salt
            var keyMaterial = GetEncryptionKeyMaterial(password, saltBuffer);

            //create a key for encrypting
            var symProvider = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesCbcPkcs7);
            var symKey = symProvider.CreateSymmetricKey(keyMaterial);

            //encrypt the plain text with key and salt material
            var cypherBuffer = CryptographicEngine.Encrypt(symKey, dataBuffer, ivBuffer);

What would be my best option for getting the same encryption to work on both UWP app and my WPF app? Note: I want to avoid using third party encryption libraries, but may consider it if no other viable option exists.

Thanks


Neptune Century


How do you get the actual height/width of a control when it shows either 0.0 or IND

$
0
0

What I am trying to accomplish is to split a canvas in two with two controls (happens to be a grid but doesn't really matter).  The first control takes up half the space to the left and the second control should take up the remaining space.

Don't tell me to use a grid with columns as I need the two controls to have visual access to the entire canvas as animations will be done on them.  

I am using the following XAML for the second control:

<Grid x:Name="FlipGridRight" Canvas.Top="0" Canvas.Left="{Binding ElementName=MainGrid, Path=Width  ,Converter={StaticResource SecondPage}}"
                      Width="{Binding ActualWidth, ElementName=RightListBox, Mode=OneWay}"
                      Height="{Binding ActualHeight, ElementName=RightListBox, Mode=OneWay}" ><Grid.Background><VisualBrush Visual="{Binding ElementName=RightListBox}"></VisualBrush></Grid.Background></Grid>

Now it picks up the correct width and height but the attempt to set the Canvas.Left through a converter fails.  Whenever the converter is invoked (only once) if I try using ActualWidth the value passed to the converter is IND and if I use Width the value is 0.0.

When do those values become useful?


Lloyd Sheen

Using AutoSuggestionBox to filter out a list of TimeZones in the world

$
0
0

Hello, I am making a world cock styled application and I want to use AutoSuggetionBox to search for a location and get details such as Place, Time and Date. For example The user searches for New York and a filtered list of possible matches of new York comes up and selecting one extracts the Name of the Place, Time and Date.

Thanks.

WPF Dispatcher Queries

$
0
0
Hello ,

I have studied a whole lots on dispatcher , but i have had some queries which i was asked in some interview and want to verify if i am wrong or right.

1) Can we create a ui element at runtime in a different thread in WPF? I am not clear about this question. The first question would be can we create UI elements in a different thread. If yes what would be the dispatcher scenario then.
2) Can we have more than one dispatchers in WPF Application? I think its a NO
3) Can a WPF Application have multiple UI Threads? I think NO
4) If we are launching the form using Form.Show() in WPF, will it launch another dispatcher?Again No

Vishal Kumar Singh

Viewing all 18858 articles
Browse latest View live


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