|
What you need to do is implement the IWin32Window interface on your WPF Window so it looks something like this:
public class MainWindow : Window, IWin32Window
{
public IntPtr Handle
{
get
{
return new WindowInteropHelper(this).Handle;
}
}
} Now, you can get this handle from any user control by casting the main window to IWin32Window.
|
|
|
|
|
Hi Pete,
I'm not sure I totally understand.
In the snippet you provided, that allows me to get the handle of the MainWindow, but I don't see how I would the handle of a control that the video can be displayed in.
Could you elaborate a bit more please?
Thank you
If it's not broken, fix it until it is
|
|
|
|
|
Basically, you need a handle to the window that you are going to display your content in. There is no such thing as a handle at the level of a user control, it applies to the window that displays it. That's all you need - the Handle to the containing window.
|
|
|
|
|
That's not going to work then. I have other content to be displayed along side the 2 videos. using the window handle would cause the video to consume the entire window.
I'm looking at WPFMediaKit on CodePlex. Looks promising.
If it's not broken, fix it until it is
|
|
|
|
|
I want to change the fontsize of the Window.Title,
But I found < Window FontSize = "14" > not worked for the Title,
just for the content of window.
|
|
|
|
|
You need to customise the window's "chrome". If you're using .NET 4.5, the classes to do this are built-in[^]. For earlier versions, there's a library[^] you can use, although the site seems to be down at the moment.
There's even a demonstration of how to use it here on CodeProject:
WPF Custom Chrome Library[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
<Window.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="Comic Sans MS"/>
<Setter Property="FontSize" Value="20"/>
</Style>
<Style TargetType="{x:Type Button}" x:Key="ButtonStyle">
<Setter Property="Height" Value="36"/>
<Setter Property="Width" Value="60"/>
</Style>
</Window.Resources>
<Grid>
<Button Content="Button" Style="{StaticResource ButtonStyle}"/>
<Button Content="Button" Style="{StaticResource ButtonStyle}" Margin="156,144,286,145" />
<TextBlock HorizontalAlignment="Left" Margin="108,38,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="154" Height="40"/>
</Grid>
I am a rookie in WPF, I am wonder why the Button need :
Style="{StaticResource ButtonStyle}" , a explicit Style syntax.
But the TextBlock don't need it.
Thanks
|
|
|
|
|
I assume you did not write the code for this! Somewhere the author has defined a style called ButtonStyle , probably in a resources folder. It will be defined in your App.xaml file as a resources dictionary, or possibly in your window/page .xaml file.
The author has decided to customise the standard layout of the Button but not the TextBox.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks,
Yes, I wrote code like that,I wonder why the Setter for Button not works for all Buttons without .
But, the Setter for TextBlock works for all TextBlocks, don't need to type <Style StaticResource ...>
|
|
|
|
|
In the "Resources" section, you assigned a "Key" ("ButtonStyle" in this case ... it could have been called "Foo") to the Button style; the TextBlock style doesn't have a Key.
Any style with a "Key" needs to be referenced via that Key (e.g. StaticResource ButtonStyle) in order to be applied to the relevant control.
The TextBlock style (in this case) is applied to any TextBlock that is in the "scope" of that style (without needing a Key).
|
|
|
|
|
I have a Border inside a DataTemplate for a ListBox. When the mouse is over the item, I want to show the Border. Here's my XAML:
<ListBox Grid.Row="3"
Grid.Column="0"
ItemsSource="{Binding Devices}"
SelectedItem="{Binding SelectedDevice}"
MaxWidth="350">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
</Style.Resources>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="SteelBlue"
BorderThickness="0"
HorizontalAlignment="Stretch"
CornerRadius="3"
MinHeight="65"
Margin="3">
<Border.Style>
<Style>
<Style.Triggers>
<Trigger Property="Border.IsMouseOver" Value="True">
<Setter Property="Border.BorderThickness" Value="1" />
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="0"
Source="/DFT.Falcon6.UI.Desktop;component/Media/Images/fc6logo.png"
Height="50"
Width="50"
Margin="5"/>
<TextBlock Grid.Row="0"
Grid.Column="1"
Text="{Binding UnitIdentifier}"
Style="{StaticResource devicetextStyle}"
Margin="2"/>
<TextBlock Grid.Row="1"
Grid.Column="1"
Text="{Binding IPAddress}"
Style="{StaticResource devicetextStyle}"
Margin="2"/>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You can see that I have a trigger defined in the Border control to set the BorderThickness to 1. However when I run it and mouse over the item, nothing happens.
What am I doing wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
In a dodge to get around the policy where we do not have access to the UAT servers I need to execute a stored procedure after a click once publish event. The proc will copy the published files to the deployment folder on the UAT server which SQL Server can see but the developers cannot.
This is currently being done by opening up MSSQL and executing the scripts, I would like to automate that by including a Post Deployment action but there does not seem to be such a creature!
Any suggestions...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ehm, any reason that the question is posted under Silverlight/WPf forum?
|
|
|
|
|
Click once, WPF application. Possibly should be in the VS forum!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Please share the video tutorial source for Entity Framework which uses WPF app as example.
|
|
|
|
|
|
Any free video tutorial web link
|
|
|
|
|
Hello team,
I have to develop a WPF based windows App that run on tablets (be pc tablet or which ever tablet family). I dont have to sell the app, its for internal use. Now, what is the type of app i have to do for?
1. Windows store app ? or windows desktop app?
what is this WindowsRT apps?
My system environment is:
1. HP elitebook revolve 810 tablet pc.
2. windows 8.1 x64 bit.
3. visual studio 2012 express.
I am confused and not able to choose the right documents to read from the msdn website. Please help
|
|
|
|
|
<Window x:Class="WpfTst1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="HTM Service Tool" WindowState="Maximized" WindowStartupLocation="CenterScreen"
FontFamily="Global San Serif" FontSize="14" Icon="pack://application:,,,/Resource/Icon/Truck16X16.ico"
>
<Window.Background>
<ImageBrush ImageSource="pack://application:,,,/Resource/Image/H1.jpg"></ImageBrush>
</Window.Background>
<Grid >
<Menu Height="24" IsMainMenu="True" VerticalAlignment="Top" HorizontalAlignment="Left" >
<MenuItem x:Name="FileMnu" Header="_File" HorizontalAlignment="Left" >
<MenuItem Header="_Login" ></MenuItem>
<MenuItem Header="_Exit" > </MenuItem>
</MenuItem>
</Menu>
</Grid>
</Window>
Don't know why the Fontsize="14" attribute not works on MenuItem, File,Login,Exit.
|
|
|
|
|
Because the default style applied to all Menu controls overrides the font size:
<Style TargetType="{x:Type Menu}">
<Setter Property="TextElement.FontSize">
<Setter.Value>
<DynamicResource ResourceKey="{x:Static SystemFonts.MenuFontSizeKey}" />
</Setter.Value>
</Setter>
</Style>
As documented on MSDN[^], values set in a Style override values inherited from parent controls.
You either need to set the font size explicitly on the Menu , or create and apply a new Style for the Menu .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
HI All,
Can any one share sample code where using tree view with check box based on below data dynamically.
Also how can i read which check box is selected or not mean how i can read check box value whether its selected or not thru loop.
{ Name = "R1", Id = 1, ParentId = 0 },
{ Name = "R2", Id = 2, ParentId = 0 },
{ Name = "R3", Id = 3, ParentId = 0 },
{ Name = "D1R1", Id = 4, ParentId = 1 },
{ Name = "D2R2", Id = 5, ParentId = 2 },
{ Name = "D3R3", Id = 6, ParentId = 3 },
{ Name = "T1D2R2", Id = 7, ParentId = 5 },
{ Name = "T2D2R2", Id = 8, ParentId = 5 },
{ Name = "T3D1R1", Id = 9, ParentId = 4 },
{ Name = "T4D3R3", Id = 10, ParentId = 6 },
{ Name = "T5D3R3", Id = 11, ParentId = 6 },
{ Name = "D4R3", Id = 12, ParentId = 3 },
{ Name = "D4R3", Id = 13, ParentId = 3 }
|
|
|
|
|
|
At one time the Epxression Blend team had one available[^] but the download link no longer works.
I was able to get the assembly, but I'd like the code.
Anyone have one of these, or know of one? Source would be nice.
If it's not broken, fix it until it is
|
|
|
|
|
|