wpf-controls

Text content in a WPF button not being centred vertically

拟墨画扇 提交于 2019-12-21 03:19:18
问题 Is there a reason why the text content of a WPF button is appearing with unwanted space above the text? I have a button in a StackPanel. This button is a simple close button so I want it to appear as a square button with an "x" centred in it. I have set my padding to zero and set both the HorizontalContentAlign and VerticalContentAlign to Center but the "x" still appears at the bottom of the button (or even truncated should I have my FontSize too big relative to my Height). It's as if there

Volume Slider like VLC

我的梦境 提交于 2019-12-21 02:53:07
问题 I am searching for Volume Slider that looks and behave just like VLC's slider. I found the following post about how to style the slider: Volume Slider CustomControl but I also want the same behavior... What is the difference between the behaviors: When you click on the slider [at the WPF] and move the mouse on the slider area (while mouse button still being hold) it should move the slider also to the position of the mouse on the slider. I couldn't find how to do it.. maybe I should use

Grid Splitter problem in WPF

▼魔方 西西 提交于 2019-12-20 18:35:55
问题 I want a layout like VS 2008. In which I want two columns and second columns is again split into two. I done that in the xaml mentioned below, but the GridSplitter is not visible vertically ( which split two columns). I want both the GridSplitter s to be resizable. One GridSplitter resizes the Left Hand Pane and Right Hand Pane and another GridSplitter resizes the subgrid's top pane and right pane.. The Second GridSplitter is working through this XAML but I am not able to produce XAML code

Set Image source from Resources in WPF application

守給你的承諾、 提交于 2019-12-20 10:56:17
问题 Can anyone show me how can I set source to image from Resource in XAML. Currently I have <Image x:Name="img" Panel.ZIndex="1" Source="D:\Img100.jpg" Stretch="Uniform"/> I want Image Source to be come from Resources. Thanks. 回答1: First you will have to include the image in your project with BuildAction Resource Then you can use it directly in your Image <Image Source="Img100.jpg"/> Or make a reusable resource of the image App.xaml (or other resource dictionary) <Application.Resources>

Styling the indeterminate state of a WPF checkbox

我的未来我决定 提交于 2019-12-20 10:46:55
问题 I want to style the indeterminate state of a WPF checkbox. We have a treeview control with checkboxes, and we want the indeterminate state to represent that some descendants are checked and some are unchecked. The solution I'm seeing everywhere is to override the default control template for a checkbox and do what I need to do. I have two problems with that: I can't find the control template for a normal Aero checkbox. This one: http://msdn.microsoft.com/en-us/library/ms752319.aspx looks

Is it possible to rearrange tab items in tab control in wpf?

冷暖自知 提交于 2019-12-20 10:39:23
问题 Is it possible to rearrange tab items in tab control in run time? For example I have 3 tab items which are about cars and 4 tabs about house. I want to be able to rearrange them using drag and drop. Is it possible or it is something fantastic? I have Tab Control here is XAML. <TabControl x:Name="tc" Visibility="Collapsed" GotFocus="Focus" AllowDrop="True" > </TabControl> Tab items will be added in runtime. Thanks for helping me! 回答1: found a solution in the MSDN forum. Here is the link:

Emulates Windows 8 Start Menu Tile Layout Engine

天涯浪子 提交于 2019-12-20 10:17:05
问题 So anyone out there knows of sample code or control that perfectly emulates the Windows 8 Start Menu Tile Layout Engine? It should support mixed Square and Rectangle Tiles, and repacks the square tiles over or under rectangle tiles properly. Note: WrapPanel works if ALL TILES are Square. But once you mix in tiles that span 2-Squares worth of space, the layout breaks, and is inconsistent with the Windows 8 Start Menu I am expecting code that extends the WPF Panel. Disclaimer: Yes I have

How to hide a part of a WPF control

走远了吗. 提交于 2019-12-20 09:55:35
问题 Is it possible to hide a part of a WPF control? .NET 4 has a DatePicker which renders 4 parts, according to MSDN. Is it possible to hide (in my case) the TextBox part (probably named PART_TextBox)? I have seen examples of styling the DatePicker completely, and it involves alot of XAML, when all I want to do is hide one part of the control. 回答1: Well, I have a solution for your case :) class MyDateTimePicker : DatePicker { public override void OnApplyTemplate() { base.OnApplyTemplate(); var

Custom textblock that transforms its content to different color

拈花ヽ惹草 提交于 2019-12-20 06:47:57
问题 I will write a custom textblock that splits its text content. It will make texts diffent colors depending on conditions and the texts will be separated with commas. Commas will remain black. I don't know how to start. Could you please provide help to start? Thanks in advance 回答1: Below user control uses an items control to show each token with some random color. Usage: <local:ColorTextBlock Text="abcd,abcde, abc, abcdef, abc, abcde, "/> XAML: <UserControl x:Class="WpfApplication1

ListView.ItemContainerGenerator.ContainerFromItem(item) return null after 20 items

纵然是瞬间 提交于 2019-12-20 06:26:44
问题 first of all I want to explain what I'm trying to do. I have a ListView in a UserControl with a DataTemplate defined as a resource. I want to hide a button inside the DataTemplate. Sounds easy, but .... The code I'm using is <UserControl.Resources> <DataTemplate x:Key="Proyectos"> <DockPanel Name="Panel" Margin="0,0,0,0" MinWidth="1200" MaxWidth="1200"> <Border Margin="0" BorderBrush="Bisque" BorderThickness="1" DockPanel.Dock="Left"> <StackPanel Margin="0" Width="1135"> <DockPanel>