Looking to find how to add resize button - c#

Hello:
I have been experimenting with WPF this afternoon, Im wondering does anyone know how I can manually enable resizing ? I have my main windows set with the following properties which removes the close/min/max and resize;
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" AllowsTransparency="True"
WindowStyle="None" Background="Maroon" ResizeMode="CanResize">
</Window>
I have found how to add my own close/min/max buttons but have not found how to enable resizing.

ResizeMode="CanResizeWithGrip"

Related

Border become invisible, When ToolWindow property is used in WPF C#

I'm currently having issue in WPF. Border line is Missing when the WPF Window style property changed to "Tool Window"
<Window x:Class="DemoAssy.Demo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:resource="clr-namespace:DemoAssy.Properties"
WindowStartupLocation="CenterScreen"
ShowInTaskbar="False" Topmost="True"
WindowStyle="ToolWindow"
ResizeMode="NoResize" SizeToContent="WidthAndHeight"
Title="" MinHeight="155" MaxWidth="470" MinWidth="154">
Can anybody explain, How to get border for WPF while using ToolWindow Property.

WPF - Resize window from user control on run time

My application works with main window and user controls for every view.
the main window have default size.
I want that one of the user controls will change its size when entering the view.
when i change the size with local it changes the user control and not the width and height of the window.
Main window :
<Window x:Class="EEPromTool2.View.MainMenu"
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:viewmodels="clr-namespace:EEPromTool2.ViewModel"
xmlns:views="clr-namespace:EEPromTool2.View"
xmlns:local="clr-namespace:EEPromTool2.View"
Background="#191919"
WindowStyle="None"
ResizeMode="CanResizeWithGrip" AllowsTransparency="True"
mc:Ignorable="d"
Title="EEPROM Tool" Height="680" Width="1000"
>
User control :
<UserControl x:Class="EEPromTool2.View.Revision"
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"
mc:Ignorable="d"
d:DesignHeight="900"
d:DesignWidth="1300"
>
Thanks for any advice.

Audio but no video when playing a movie using mediaplayerelement in wpf

I am trying to use MediaPlayerElement in a WPF to play streaming videos. I have set up a simple WPF window that contains a MediaPlayerElement instance and auto-plays a video. When I run the program, I can hear audio but the video is not visible.
I started by following this tutorial:
https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/mediaplayerelement
Unfortunately the tutorial appears to be out of date, as it no longer works. I made a few corrections to get it to a running state, but cannot get the video to appear.
I have tried placing the MediaPlayerElement inside a Grid or StackPanel, but can't because it is not a UIElement.
<Window x:Class="MediaPlayerElement_Test.MainWindow"
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:MediaPlayerElement_Test"
xmlns:controls="clr-namespace:Microsoft.Toolkit.Forms.UI.Controls;assembly=Microsoft.Toolkit.Forms.UI.Controls"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<controls:MediaPlayerElement Name="mediaPlayerElement" AutoScaleDimensions="800,450"
Source="https://mediaplatstorage1.blob.core.windows.net/windows-universal-samples-media/elephantsdream-clip-h264_sd-aac_eng-aac_spa-aac_eng_commentary-srt_eng-srt_por-srt_swe.mkv"
AutoPlay="True" Anchor="Top" Height="450" Width="800" AreTransportControlsEnabled="True" />
</Window>
Does anyone know what I am doing wrong here? How do I get the video to display in the window?
Try this one, this works perfectly for me
<Window x:Class="Test.Media"
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:Test"
mc:Ignorable="d"
Title="Media" Height="450" Width="800">
<Grid>
<MediaElement Margin="10,10,10,0 " Source="http://mediaplatstorage1.blob.core.windows.net/windows-universal-samples-media/elephantsdream-clip-h264_sd-aac_eng-aac_spa-aac_eng_commentary-srt_eng-srt_por-srt_swe.mkv"
Name="McMediaElement"
Width="450" Height="250" LoadedBehavior="Play" UnloadedBehavior="Stop" Stretch="Fill"/>
</Grid>
if this is not working then it might be the issue with your video codec

Can't change DataContext WPF

I am trying to use a MVVM pattern instead of putting all logic in the code-behind file, but I can't seem to get it working.
My view is this:
<Window x:Class="WpfApp4.MainWindow"
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:WpfApp4"
mc:Ignorable="d"
xmlns:vm="clr-namespace:WpfApp4.ViewModel"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<vm:ViewModelMain />
</Window.DataContext>
<Grid>
</Grid>
And this is my ViewModel:
namespace WpfApp4.ViewModel
{
class ViewModelMain
{
}
}
What am I doing wrong here?
Visual studio can be a bit temperamental sometimes with xaml warnings and errors. Try closing the window, and/or cleaning and rebuilding the project, or if all else fails close all windows and restart visual studio

Set window icon correctly and happening XamlParseException

I set window icon property in xaml code or in the properties window correctly in a very simple wpf application, but visual studio always throws an XamlParseException at runtime. Why is this happening?(using visual studio 2013 and windows 8, my icon size is 15 KB)
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Icon="pack://siteoforigin:,,,/Resources/MyIcon.ico">
<Grid>
</Grid> </Window>
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Icon="/Resources/MyIcon.ico">
<Grid>
</Grid> </Window>
It is a problem with your image Build Action Property, check the arrows for further info..

Categories

Resources