wpf-controls

Using WPF expander control on microsoft surface platform

限于喜欢 提交于 2019-12-10 23:03:24
问题 I am trying to use the Expander control in the surface application. I have seen its not a surface control so application compiles and control shows up but the contacts are not working. Is there anyway I can modify the contact events and make it work in surface applications. 回答1: To do that, all you have to do is change the Expander 's template to use Surface controls instead of the regular controls. The Expander 's default template can be found at http://msdn.microsoft.com/en-us/library

How to shrink font size in Textblock to fit width of content AND maintain font aspect ratio

烂漫一生 提交于 2019-12-10 22:38:55
问题 Here's the deal: I have this line of XAML <Viewbox Canvas.Left="27" Canvas.Top="479" Width="377" Height="21" Stretch="Fill" StretchDirection="DownOnly" VerticalAlignment="Top" HorizontalAlignment="Left"> <TextBlock Name="TitleText" TextWrapping="Wrap" TextAlignment="Left" FontSize="14" FontStretch="Normal" FontStyle="Normal" Foreground="White" Width="377" >some long text here </TextBlock> </Viewbox> I want the font to scale down to fit the contents height and width. What happens now is that

WPF: Can't control keyboard focus

隐身守侯 提交于 2019-12-10 22:24:26
问题 I'm having a problem that has been driving me up the wall this week. Summarized, the issue is that i am unable to give keyboard focus to a ComboBox from code when i left click on another control. To be specific, i have a CustomControll which has a Scrollview with another CustomControll in it and a another CustomControll with a ComboBox as children. I'll illustrate this to make it clear: ScrollView DayView (CustomControl) ScrollView Some irrelevvant controls TimelineEvent (CustomControl)

how to avoid click when I want double click?

本秂侑毒 提交于 2019-12-10 21:53:02
问题 I have an application in WPF and one button. In this buttun I want the click event that implement a code, but I want that when the do double click with the mouse, execute other code but not the code of the click event. The problem is that the code of the click event is always executed and I don't know if there is a way to avoid the execution of the click event when I do doulbe click. I am follow the MVVM pattern and I use MVVM light to convert the event into a command. Thanks. 回答1: Set the

Close all open modal dialog windows

怎甘沉沦 提交于 2019-12-10 20:58:26
问题 I have a WPF application that has several modal window used for various purposes. This is easily accomplished by using the ShowDialog function. However, in my application I have a timer to measure idle time (i.e. no mouse moves or key strokes) that will cause the user to be logged off. Is there a way (when this timer fires) to find and close all open modal windows without tracking each explicitly? Update I would also like to close any MessageBox.Show instances. Is this possible? Thanks, Matt

Toolbar Overlay over WindowsFormsHost

亡梦爱人 提交于 2019-12-10 20:08:39
问题 I have a SWF object embedded in a WindowsFormsHost Control inside a WPF window. I'd like to add a toolbar over the swf movie. The problem with the snippet of code I have below, is that when the new child is added to the host control (or the movie is loaded, I haven't figured out which yet), the toolbar is effectively invisible. It seems like the z-index of the swf is for some reason set to the top. Here is what it looks like: XAML: <Grid Name="Player"> <WindowsFormsHost Name="host" Panel

wpf: How to add a Hyperlink at runtime?

时光毁灭记忆、已成空白 提交于 2019-12-10 19:49:39
问题 I need to add several hyperlinks to the program's form dynamically at runtime (and handle user clicks on them). How to do this? I tried something like: var hlink = new Hyperlink(); myStackPanel.Children.Add(hlink); but hyperlink is not a UIElement... Thanks! 回答1: It's a little bit kludgy, but you need to do this: Label linkLabel = new Label(); Run linkText = new Run("Google"); Hyperlink link = new Hyperlink(linkText); link.NavigateUri = new Uri("http://www.google.com"); link.RequestNavigate +

Button ControlTemplate and rounded corners

耗尽温柔 提交于 2019-12-10 19:07:30
问题 I have a controltemplate for buttons. I want to make the buttons with rounded corners. How should I do this? I tried CornerRadius for button in the Border but it doesn't work. The background of the button has set to an image that has corner borders and the button looks akward as I can't set the corners for the button. 回答1: Try the following: <Style x:Key="GlassButton" TargetType="{x:Type Button}"> <Setter Property="FontSize" Value="42" /> <Setter Property="Foreground" Value="White" /> <Setter

WPF data validation and display error message IDataErrorInfo and error templates

烂漫一生 提交于 2019-12-10 18:53:51
问题 How to do WPF data validation for error and display error message using IDataErrorInfo and error templates 回答1: ViewModel: IDataViewModel.cs using GalaSoft.MvvmLight; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IDataErrorInfo_InputValidation.ViewModel { class IDataViewModel:ViewModelBase,IDataErrorInfo { public string FirstName { get; set; } public string LastName { get; set; }

WPF Nested Styles

孤街浪徒 提交于 2019-12-10 18:19:41
问题 I have TextBlocks and Comboboxes in my application i want the Textblock foreground to be white and the Combobox Foreground to be Black. What i tried was: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Foreground" Value="White" /> </Style> <Style TargetType="{x:Type ComboBox}"> <Setter Property="Foreground" Value="Red" /> </Style> <