Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate vista glass effect on wpf with custom color
    primarykey
    data
    text
    <p>There are a lot of tutorials that show you how to use vista glass effect in wpf application like <a href="https://i.stack.imgur.com/HSNoE.png" rel="nofollow noreferrer">this one</a>. </p> <p>I don't want to use the default color theme that the user selects. In other words if I apply the vista glass efect to my wpf application it will be equal to whatever the user selects in:</p> <p><img src="https://i.stack.imgur.com/HSNoE.png" alt="enter image description here"></p> <hr> <h2>This is what I have tried and it is somewhat of a solution:</h2> <blockquote> <p><strong>1) get a picture of the entire desktop. I will later figure out how to do this with code</strong></p> <p><strong>2) place the image in a canvas. I happen to have outlook open when I took the capture of my desktop. Also place a rectangle on top with the color that you want to use with some transparency</strong></p> </blockquote> <p><img src="https://i.stack.imgur.com/HSNoE.png" alt="enter image description here"></p> <blockquote> <p><strong>3) Create the properties X and Y, implement the INotifyPropertyChanged interface so that we may update the position of the image in code behind:</strong></p> </blockquote> <pre><code>public partial class MainWindow : Window, INotifyPropertyChanged { double _X; public double X { get { return _X; } set { _X = value; NotifyPropertyChanged("X"); } } double _Y; public double Y { get { return _Y; } set { _Y = value; NotifyPropertyChanged("Y"); } } public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } </code></pre> <p><strong>Dont forget to set: <code>this.DataContext = this;</code> in order to succesfuly bind the properties when the window is done loading</strong></p> <blockquote> <p><strong>4) Now we need to place the image with position relative to the desktop not to the window. So we create an event handler whenever the window moves we fix the position of the image like:</strong></p> </blockquote> <pre><code>void MainWindow_Loaded(object sender, RoutedEventArgs e) { this.DataContext = this; this.LocationChanged += new EventHandler(MainWindow_LocationChanged); } void MainWindow_LocationChanged(object sender, EventArgs e) { X = -((System.Windows.Window)(sender)).RestoreBounds.TopLeft.X; Y = -((System.Windows.Window)(sender)).RestoreBounds.TopLeft.Y; } </code></pre> <h2>Finally you should have something like:</h2> <p><img src="https://i.stack.imgur.com/iC7eY.png" alt="enter image description here"></p> <p><strong>This solution will work great if I where to have an image of the entire desktop. Every time the desktop changes I will have to update the image source. Also when updating the image source I will have to capture the desktop image without my window. I don't know how to get an image of the desktop without my main window. Maybe I will have to hide my window get the screen capture and then show my window again</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload