wpf-controls

wpf datagrid alternate row coloring

戏子无情 提交于 2019-12-17 15:46:36
问题 I have tried this method.. without luck.. <Style TargetType="{x:Type DataGridRow}"> <Style.Triggers> <Trigger Property="ItemsControl.AlternationIndex" Value="0"> <Setter Property="Foreground" Value="Red" /> </Trigger> </Style.Triggers> </Style> Is there a way to get the row Index? I have even tried <DataTrigger Binding="{Binding AlternationIndex}" Value="0"> <Setter Property="Foreground" Value="Green"></Setter> </DataTrigger> 回答1: Unless already done, you have to set the AlternationCount

WPF: Cancel a user selection in a databound ListBox?

那年仲夏 提交于 2019-12-17 15:36:18
问题 How do I cancel a user selection in a databound WPF ListBox? The source property is set correctly, but the ListBox selection is out of sync. I have an MVVM app that needs to cancel a user selection in a WPF ListBox if certain validation conditions fail. Validation is triggered by a selection in the ListBox, rather than by a Submit button. The ListBox.SelectedItem property is bound to a ViewModel.CurrentDocument property. If validation fails, the setter for the view model property exits

How to implement Balloon message in a WPF application

吃可爱长大的小学妹 提交于 2019-12-17 10:42:19
问题 We would like to use balloon messages as described in the UX Guide from Microsoft. I found some samples which uses native code from Windows Forms, but the native code requires a handle to the component which a bit difficult for a WPF application since it doesn't follow the same concept. I found some sample code which uses WPF's decorator mechanism, but I'm still not convinced that this is the easiest approach for WPF application. Could a possible implementation be to implement a decorator

Content of a Button Style appears only in one Button instance

谁都会走 提交于 2019-12-17 10:03:49
问题 I have a Viewbox: <Viewbox x:Key="SampleViewbox" > <Grid> <Ellipse Stroke="#e2e2e0" StrokeThickness="6" Fill="#d5273e" Width="128" Height="128"/> </Grid> </Viewbox> I then include this in a Style like: <Style x:Key="SampleStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border Background="Transparent" > <ContentPresenter Content="{StaticResource SampleViewbox}"/> </Border> </ControlTemplate> </Setter.Value> <

Set WPF webbrowser control to use IE10 mode

北战南征 提交于 2019-12-17 09:51:33
问题 How can i set the WPF webbrowser controls to render pages in iE10 mode or the higher version installed on machine . By default if i create a .net 4 or .net 4.5 application on any machine of OS > windows 7 , it renders the html pages in IE7 mode only. (Please correct if i am wrong) How to enable the application to render the html pages in IE10 mode if IE10 installed on target machine ? Any helps 回答1: You can use the registry as described here: http://msdn.microsoft.com/en-us/library/ie

How do I host WPF content in MFC Applications?

流过昼夜 提交于 2019-12-17 09:00:16
问题 I'm going to answer my own question here because I spent a few hours piecing this together and wanted to share what I found in the hope that I will save someone else the digging. There is an MSDN Walkthrough that gets you most of the way there, but there are a couple of key pieces that I found elsewhere. For example, the walkthrough tells you to place the line [System::STAThreadAttribute] before the _tWinMain() definition but if you're implementing a standard MFC application then you don't

Difference between Visibility.Collapsed and Visibility.Hidden

别来无恙 提交于 2019-12-17 07:03:56
问题 What are differences between Visibility.Collapsed and Visibility.Hidden in WPF? 回答1: The difference is that Visibility.Hidden hides the control, but reserves the space it occupies in the layout. So it renders whitespace instead of the control. Visibilty.Collapsed does not render the control and does not reserve the whitespace. The space the control would take is 'collapsed', hence the name. The exact text from the MSDN: Collapsed : Do not display the element, and do not reserve space for it

LISTBOX grouping using collectionView Source

…衆ロ難τιáo~ 提交于 2019-12-14 03:58:43
问题 ListBox grouping using CollectionView source programmatically: like Task 1 (certain date) Task 2 (certain date) Task 3 (certain date) Task 4 (certain date) to Certain date1 Task 1 Task 3 Certain date2 Task 2 Task 4 回答1: Here is a sample for you. XAML: <Window x:Class="TestWPFApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="695" Width="996" Loaded="Window_Loaded"> <Grid> <ListBox

Binding a slider value on the height of its thumb in WPF

天大地大妈咪最大 提交于 2019-12-14 03:53:14
问题 I have a databinding problem in WPF. I would like to "customise" a slider in a way that the thumb grows when you move the slider to the right and the thumb shrinks when you move the slider to the left. So I edited the template for the slider and changed the look of the slider so the slider looks like I want it to. But now I have to bind the height of the thumb to the value of the slider but I do not know how that works. I did some simple data binding things but I cannot figure out how I can

DockPanel.Dock=“Right” is not working for single control on Maximized window?

 ̄綄美尐妖づ 提交于 2019-12-14 03:41:25
问题 I am using DockPanel.Dock for docking controls at the specific place(i.e left/right). The problem is my controls are not docking according to the DockPanel.Dock position. Below is the code for single control with DockPanel.Dock="Right" <DockPanel> <TextBlock Text ="Left1" Margin ="5" DockPanel.Dock ="Left" Style ="{StaticResource TextBlockStyle}" /> <TextBlock Text ="Left2" Margin ="5" DockPanel.Dock ="Left" Style ="{StaticResource TextBlockStyle}" /> <TextBlock Text ="Right1" Margin ="5"