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

Logging In With A PIN

$
0
0

I have been trying to log in to my Windows 10 developmennt PC using a PIN instead of a password, and have followed the directions given on web sites such as this:

https://www.digitalcitizen.life/how-create-login-pin-code-or-picture-password-windows-10

However despite following all instructions and defining a PIN for the logon, when I attempt to log on to the development PC using a PIN I am consistently met with the following objection:

However the same logon on the same LAN/domain and same domain controller logs on flawlessly on another PC, so I am at a loss to understand where the problem is.


AndrewM


MVVM : Not able to Access Properties of Child UserControl ...But Able to Access MainWindow.

$
0
0

MVVM : Not able to Access Properties  of Child UserControl ...But Able to Access MainWindow.

 var windows = Application.Current.Windows.OfType<Window>();

CefSharp library WPF, User Interface block/stuck while loading of any web URL

$
0
0
Hello, 
We are using the CefSharp WPF version ( https://github.com/cefsharp/CefSharp ) in our WPF window/desktop app. We are using .net framework 4.5 along with the 64 bit version of the CefSharp version 6.3.0.3.0
Whenever any web URL loading in the CefSharp browser the other user interface and animation in the app gets block/stuck during loading. After loading gets finished in the browser, user interface and animations in the app works well.
Any way we can avoid this stuck/block issue while loading of any web URL in the CefSharp browser?

Thanks,
Sandeep Prajapat

Use a generic type in xaml file

$
0
0

Hi !

I'm using a specific control where I can specify the type I want to use with, something like this:

<grids:PropertyEditor PropertyType="drawing:Color"><...></grids:PropertyEditor>

Is there a way I can specify, instead of Color, any type coming from IList ? something like :

<grids:PropertyEditor PropertyType="generic:IList"><...></grids:PropertyEditor>

I saw some post about this but always about a specific thing like only List<string> and not any List.

Any idea ?

Antoine P


PICARD Antoine - Young Dev

Navigate from VB page to C# page WPF

$
0
0

I am wondering how to make this work in wpf.  I have a solution with 2 projects, one in VB and one in C#.  How can I navigate from the VB to the C# page and vice versa via a button click.  Normally if all the code was in C# I would just do a navigation service like this:

 private void Button_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(
            new Uri("WpfApp2VB.HomeVb.xaml", UriKind.Relative));
        }

However when I do this I get the error 

'Cannot locate resource 'wpfapp2vb/homevb.xaml'.
Thanks for any advice

how do I set a timer for Button_PreviewMouseLeftButtonUp event?

$
0
0

Hi,All. I have a Button_clicked events and a Button_PreviewMouseLeftButtonUp events. Now when I click my button, both of events are called. How can I set a timer for Button_PreviewMouseLeftButtonUp event, says if I pressed button for more than 1 second then Button_PreviewMouseLeftButtonUp event is called, otherwise Button_clicked events is called.

Get all Active or Alive or instantiated ViewModel...Without MVVMl Light or Third Party tools

$
0
0

var nav = SimpleIoc.Default.GetInstance<INavigationService>();

   SimpleIoc.Default.Register<MainViewModel>();                  
        SimpleIoc.Default.Register<SecondViewModel>(); 

Above Code Works Using MVVM Light.....But in my current Project no third Dll's Allowed....How Can I Achieve It..

How to create pages for wpf application

$
0
0

Hi

I have been struggling to develop a simple text editor application similar to MS Word, Pages etc. The software application should contain a4 pages. Once one page filled then another page should append below the current. 

So far, I have abled to figure out rest of functionality but stuck at this point. I could not able to understand the page and what it is exactly. 

Please look at the following images. 

Ignore the text in it. I am trying to understand what is the white section exactly. 

In HTML Pages, the white section would be iframe with editable mode on. So in WPF Application, what would be the white section. This white section is page in the software upon which user could able to type text. Once the page fills, next page appears below it. 

Hope you understood my question. Sorry for the bad english. Please guide me. Thanks. 


Avoid Expose connection string in WPF project app.config

$
0
0

I have WPF project and class library is handling EF 6.0 with Database first approach. Now i want entity classes into my startup project(WPF project) without adding connection string in startup project app.config. I google out class EntityConnectionStringbuilder that will help to generate dynamically connection string. But, I can't find solution with database first approach and entityconnectionstringbuilder.

Let say, if i write using(var dbentities = new DB_Entities()) so where to pass connection string and DB_Entities constructor is auto generated as I have DB first approach

Please help me to pass connection string in Db first approach or any other thing related to db first.

WPF animation running at 67FPS and tearing

$
0
0

I have a laptop and a desktop. On my laptop, WPF animation is smoothly running at 60FPS, but on my desktop, it runs at 67FPS, and it tears since my screen's refresh rate is 60FPS.

How can I ask WPF to synchronize the animated rendering with the screen refresh, to avoid tearing?

Calling Timeline.SetDesiredFrameRate does not improve much.

How to close a Button.ContextMenu programmatically?

$
0
0

Is it possible to programmatically close a Button.ContextMenu? The reason I ask is because I have a Navigation Tray item that displays a WPF Window upon click on the tray icon. My client wants the Window to hide when it loses focus and this works. On the WPF Window is a Button that has a built in ContextMenu. When the button is clicked the ContextMenu displays. When the user clicks on the desktop the WPF Window notices its loss of focus and is collapsed. The problem is, the ContextMenu is left still visible on the display after the WPF Window has been hidden. The Button.ContextMenu has an IsOpen property so I bound that to a property in the ViewModel and, upon hiding the Window, a false was written into that property. Surprisingly, this did not close the ContextMenu. Nada. Nothing. ContextMenu remained visible. I was pretty sure that the binding was correct but, just to be sure, I violated MVVM and wrote a false to the attribute directly from the View itself. Still no joy. I'm beginning to suspect that IsOpen doesn't respond to a false being written to it. Very puzzling. Is there some way to programmatically close a ContextMenu?

This is a slightly simplified definition of the button and its context menu.

<Button
    Height="25" Width="20"
    x:Name="btnTripleDot"
    Command="{Binding CmdTripleButton}" ><Button.Style><Style TargetType="{x:Type Button}"><Style.Triggers><EventTrigger RoutedEvent="Click"><EventTrigger.Actions><BeginStoryboard><Storyboard><BooleanAnimationUsingKeyFrames 
Storyboard.TargetProperty="ContextMenu.IsOpen"><DiscreteBooleanKeyFrame KeyTime="0:0:0" Value="True"/></BooleanAnimationUsingKeyFrames></Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Style.Triggers></Style></Button.Style><Button.ContextMenu><ContextMenu><MenuItem Header="Add Account" Command="{Binding CmdAddAccount, Source={StaticResource ViewModel}}" /><Separator /><MenuItem Header="Help" Command="{Binding CmdHelp, Source={StaticResource ViewModel}}" /><MenuItem Header="PreVeil Website" Command="{Binding CmdPreVeilWebsite, Source={StaticResource ViewModel}}" /><Separator /><MenuItem Header="Quit" Command="{Binding CmdQuit, Source={StaticResource ViewModel}}" /></ContextMenu></Button.ContextMenu><Button.Template><ControlTemplate><Image Source="/KeyMenu;component/Resources/keymenu_more_32.png" /></ControlTemplate></Button.Template></Button>

Here's an example of the direct access to the IsOpen property being cleared.

protected override void OnDeactivated( EventArgs e )
{
    base.OnDeactivated( e );

    // TopRowV is the UserControl that contains the button.
    if (TopRowV != null)
        TopRowV.btnTripleDot.ContextMenu.IsOpen = false;

    // Call a function that hides the Window.
    Hide();
}


Richard Lewis Haggard

Could not load file or assembly Microsoft.Practices.Unity version=4.0.0.0 culture=neutral, PublicKeyToken=6d32ff45e0ccc69f

$
0
0
I've seen other posts with similar descriptions, but not exactly this one.  My app is a WPF MVVM with Prism, Unity and CommonServiceLocator.  Everything was fine until I decided to upgrade to the latest Prism and Unity versions. The NuGet version of Unity is v5.8.9.  Prism.Unity version is v6.3.0.  Prism.WPF version is v6.3.0.  Prism.Core version is v7.0.0.396.  And of course there are a slew of other assemblies installed via NuGet.  I suspect one of them must be referencing Microsoft.Practices.Unity v4.0.0.0, but I would not know how to verify that.

Rob E.

I wanna know how to get searchbox for mtable in datagrid .... in WPF project...

calling WPF function inside c++ from second thread

$
0
0

I want create process which will show result in to WPF after cycle. For instance, I want update progressbar after cycle inside loop.

I read this documentation https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/threading-model but I am not sure if I can call from second thread, inside unmanaged code, c# function, which update GUI.


How to insert image from image control into WPF to SQL Database using entity data model

$
0
0

Hi, Guys
i am creating an app to save student information into SQL , I want to know how to insert image from image control in WPF using entity framework to SQL database

i made event to upload image into image control and now i need to save it to sql database using entity framework

privatevoid uploadbt_Click(object sender,RoutedEventArgs e){OpenFileDialog op =newOpenFileDialog();
         op.Title="Select a picture";
         op.Filter="All supported graphics|*.jpg;*.jpeg;*.png|"+"JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|"+"Portable Network Graphic (*.png)|*.png";if(op.ShowDialog()==true){
             photo.Source=newBitmapImage(newUri(op.FileName));}}

this is my database named cv

this is my code to save some information into database this cose for save button

                         
facultymakerEntities1 entity = new  facultymakerEntities1();

             cv CV = new cv();
             CV.Full_Name = fullnametb.Text;
             CV.Activities = activitestb.Text;
             CV.Address = addresstb.Text;
             CV.Birth_Day = bddate.SelectedDate.Value;
             CV.Courses = cousetb.Text;
             CV.E_Mail = emailtb.Text;

             entity.cvs.Add(CV);
             entity.SaveChanges();
how can i save image from image control into database ?

thanks;


Mohamed Safwat Software Developer


Google Forms

$
0
0

Hi,

I'm doing a google form and I want the people who answer to view one part of the form or another depending on an answer at the beggining. How can I do that?7

Thanks

Custom Property Binding Difference Data with UI

$
0
0

I've made derived image control class, that accepts image path, but when I use binding, some images display other record image; although data is right. Is it image property invalidate or something?

https://giphy.com/gifs/2A67UcAnOIjLDDkBE7

ImageUserControl.cs

using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace WpfApp1
{
    static class BitmapHelpers
    {
        public static BitmapImage ToBitmapImage(Uri source)
        {
            var bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.UriSource = source;
            bitmap.CacheOption = BitmapCacheOption.OnLoad;
            bitmap.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
            bitmap.EndInit();
            return bitmap;
        }

        public static string GetThumbnailPath(string fullPath)
        {
            return Path.Combine(Path.GetDirectoryName(fullPath),
                "thumb" + Path.GetFileName(fullPath));
        }
    }

    public class ImageUserControl : Image
    {
        public static readonly DependencyProperty CanOpenFileExternallyProperty;
        public static readonly DependencyProperty UseThumbnailProperty;
        public static readonly DependencyProperty UriSourceProperty;

        private string OriginalPath { get; set; }
        private string ThumbnailPath { get; set; }

        static ImageUserControl()
        {
            UseThumbnailProperty = DependencyProperty.Register("UseThumbnail", typeof(bool), 
                typeof(ImageUserControl), 
                new FrameworkPropertyMetadata(false));
            UriSourceProperty = DependencyProperty.Register("UriSource", typeof(string), 
                typeof(ImageUserControl), 
                new FrameworkPropertyMetadata(null, OnUriSourcePropertyChanged));
        }

        private static void OnUriSourcePropertyChanged(DependencyObject d,
                     DependencyPropertyChangedEventArgs e)
        {
            ImageUserControl uc = d as ImageUserControl;
            uc.UriSource = e.NewValue.ToString();

            try
            {
                string value = e.NewValue.ToString();
                uc.OriginalPath = value;
                if (uc.UseThumbnail && !string.IsNullOrWhiteSpace(value))
                {
                    uc.ThumbnailPath = BitmapHelpers.GetThumbnailPath(value);
                    if (System.IO.File.Exists(uc.ThumbnailPath))
                    {
                        uc.Source = BitmapHelpers.ToBitmapImage(new Uri(uc.ThumbnailPath));
                        return;
                    }
                }
                if (!string.IsNullOrWhiteSpace(value) && System.IO.File.Exists(value))
                    uc.Source = BitmapHelpers.ToBitmapImage(new Uri(value));
                else
                    uc.Source = null;
            }
            catch { uc.Source = null; }
        }

        public const string UriSourcePropertyName = "UriSource";

        public string UriSource
        {
            get
            {
                return (string)GetValue(UriSourceProperty);
            }
            set
            {
                SetValue(UriSourceProperty, value);
            }
        }

        public event EventHandler ImageChanged;

        public void OnImageChanged()
        {
            ImageChanged?.Invoke(this, null);
        }

        public ImageUserControl()
        {
        }

        public bool UseThumbnail
        {
            get { return (bool)GetValue(UseThumbnailProperty); }
            set { SetValue(UseThumbnailProperty, value); }
        }
    }
}

StudentViewModel.cs

using WpfApp1.Model;
using System.Collections.ObjectModel;

namespace WpfApp1.ViewModel
{
    public class StudentViewModel
    {
        public ObservableCollection<Student> Students { get; set; }

        public void LoadStudents()
        {
            ObservableCollection<Student> students = new ObservableCollection<Student>();

            students.Add(new Student { FirstName = "One", LastName = "Red", Image= @"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg" });
            students.Add(new Student { FirstName = "Two", LastName = "Green", Image= @"C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg" });
            students.Add(new Student { FirstName = "Three", LastName = "Blue", Image= @"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg" });
            students.Add(new Student { FirstName = "Four", LastName = "Cyan", Image= @"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg" });
            students.Add(new Student { FirstName = "Five", LastName = "Magenta" });
            students.Add(new Student { FirstName = "Six", LastName = "Yellow", Image = @"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg" });
            students.Add(new Student { FirstName = "Seven", LastName = "Black", Image = @"C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg" });
            students.Add(new Student { FirstName = "Eight", LastName = "White", Image = @"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg" });
            students.Add(new Student { FirstName = "Nine", LastName = "Orange", Image = @"C:\Users\Public\Pictures\Sample Pictures\Koala.jpg" });
            students.Add(new Student { FirstName = "Ten", LastName = "Gray" });

            Students = students;
        }
    }
}

MainWindow.xaml

<Window x:Class = "WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable = "d"
        Loaded="StudentViewControl_Loaded"
Title = "MainWindow" Height = "350" Width = "525"><DataGrid Name="DataGridStudents" ItemsSource="{Binding Students}" AutoGenerateColumns="False" CanUserAddRows="False"><DataGrid.Columns><DataGridTemplateColumn><DataGridTemplateColumn.CellTemplate><DataTemplate><local:ImageUserControl Height="50" UriSource="{Binding Image, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" UseThumbnail="True" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn><DataGridTextColumn Header="FirstName" Binding="{Binding Image}" /><DataGridTextColumn Header="FirstName" Binding="{Binding FirstName}" /><DataGridTextColumn Header="LastName" Binding="{Binding LastName}" /></DataGrid.Columns></DataGrid></Window>

I've also tested derived imageusercontrol with custom property, when i scrolled window very fast. Data on that property somehow pointed other record property

Setting TextBox property in Style

$
0
0

I'm trying to set the IsReadOnly property of TextBoxes in a Style, but it doesn't work.  My ViewModel has an IsReadOnly property, and I'm trying to set this to the TextBox property.  The VM property is set to 'false' using a button, and is working correctly.  I originally set the property straight to my VM property:

  <Style TargetType="{x:Type TextBox}">

     <Setter Property="IsReadOnly" Value="{Binding IsReadOnly}" />

     ...

  </Style>


but this had no effect.  Following suggestions online, I tried solutions involving RelativeSource:

 
   <Setter Property="IsReadOnly" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=DataContext.IsReadOnly}" />

but that doesn't work either.

How do i set the 'IsReadOnly' property on a TextBox using a Style that binds to a VM property?



How to get functionality similar to ms word page, wordpad page or page (software for mac) page

$
0
0

Hi

I am new to wpf. I am working on a project. Almost entire project is complete except one and for which from long time we are struggling to achieve. Searched a lot and failed to get proper response. So posting here. Sorry for my Bad English. 

My requirement is to achieve similar kind of page functionaly that ms word provide or word pad provide or page(mac os) provide. 

What I mean is..

The project is a text editing software with lots of features. I am stuck here. I want user types inside text area and the moment text typing reaches bottom of the text area then a new text area should appear below it and the typing should shift to the new text area and rest typing should continue until unless the text typing reaches the bottom. And this cycle should continue as long as user types. 

It is exact to ms word page functionality. where user once reaches the bottom of the page, a new page appear below it, and text typing automatically shifts to new page. 

I want this kind of functionality in my project. Dont know how to achieve this. Any guidance will be welcome. Please guide me. Thanks in advance. Please look in to the attachment picture for reference. The paragraph are sample paragaraph and the software which I used is page(mac os).

Excel Worksheet GUI becomes unresponsive as soon as SetParent is called

Viewing all 18858 articles
Browse latest View live


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