wpf-controls

How to get general ItemContainer type for WPF ItemsControl

拟墨画扇 提交于 2019-12-23 10:17:56
问题 I want to determine ItemContainer type from an existing ItemsControl object. var item = control as ItemsControl; //HOW to get child container Type? Example how blend does this: Blend somehow determines that current TabControl type child item is TabItem . How to do same thing in code? 回答1: There is a StyleTypedPropertyAttribute on most classes derived from ItemsControl . Get the one having Property equals to "ItemContainerStyle" . The StyleTargetType property on this attribute should give you

WPF: Adding an image to a ListBox ItemTemplate

十年热恋 提交于 2019-12-23 09:48:27
问题 I am creating a WPF app with a list box that I am binding to project names. As a decorative element, I want to place a small icon next to each item in the list, similar to the way Outlook does in its Personal Folders list. For starters, I am going to use the same image for all items in the list. Here is the markup that I've got so far (I'll move it to a resource dictionary after it's working): <ListBox.Resources> <ImageBrush x:Key="ProjectIcon" ImageSource="Images/project.png" /> </ListBox

WPF Menuitem Border

江枫思渺然 提交于 2019-12-23 09:27:31
问题 I've run into a problem trying to implement a Menu and can't figure out what is going on. I'm trying to make a single-layer menu using the Menu control. Here is my menu code: <Menu DockPanel.Dock="Top" Height="22" Name="menu1" VerticalAlignment="Top" Background="#FF325170"> <MenuItem Header="Featured" Style="{StaticResource menuItemStyle}" /> <MenuItem Header="Search" Style="{StaticResource menuItemStyle}" /> </Menu> And my style for my MenuItem s is as follows: <Style x:Key="menuItemStyle"

a clock in c# wpf application [closed]

天涯浪子 提交于 2019-12-23 05:57:13
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . i'm working on c# wpf application and i would like to add a clock to my application: how to make that clock in my application? how to make my application clock not linked to windows clock?? how to show clock by

How do you change TemplateBindings to Bindings in a button's control template, without repeating the whole control template

久未见 提交于 2019-12-23 04:52:10
问题 I want to change the background color of a button in its normal, moused-over and pressed states to various shades of green. I am forced to add the following grotesquely verbose Button.Template to my button so that I can modify the RenderMouseOver and RenderPressed attributes to use Binding instead of TemplateBinding , so that my triggers (in the Button.Style ) actually take effect instead of being ignored due to the compile time nature of TemplateBinding . Is there anyway to override these

Progress Bar not incrementing

北慕城南 提交于 2019-12-23 04:38:09
问题 I have the following code which read a file and also increment te progress bar while reading it, but i dont see any activity in my progressBar . can anyone please help me why? progressBar1.Minimum = 0; progressBar1.Maximum = (int)fileStream.Length + 1; progressBar1.Value = 0; using (fileStream) { fileStreamLength = (int)fileStream.Length + 1; fileInBytes = new byte[fileStreamLength]; int currbyte = 0, i = 0; var a = 0; while (currbyte != -1) { currbyte = fileStream.ReadByte(); fileInBytes[i++

First Listbox scrollbar movement should effect Second Listbox scrollbar movement? But How?

橙三吉。 提交于 2019-12-23 03:26:15
问题 I have 4 List Boxes in my WPF App. Each of them, at any given point of time contains equal no. of String ListBoxItems in them. If selected index of any one of them changes the other three also reflect the same behaviour. What i want is that when a user moves scrollbar of one of them the other three should also move simultaneoulsly. I tried Scrollintoview but it does not work bcoz if i select an item of a listBox and apply scrollintoview for other three Listboxes the selected item in them come

WPF map control with supported directions, search

淺唱寂寞╮ 提交于 2019-12-23 03:07:52
问题 I am searching Windows 7 compatible WPF/WinForms control that can display maps, calculate directions, perform searching and other map operations. Basically, it all doesn't have to integrated in one solution, it can be something like one control for maps display (Google or Bing or Nokia or OSM) and some library that supports all other operations, but it should be easy to integrate this two, like draw calculated route on map or fetch calculated routes from map. What i don't want is that all is

Different color for different items in ListView

跟風遠走 提交于 2019-12-23 01:52:13
问题 How can I define different colors in each row of ListView automatically? for example if I have such classes: public partial class MainWindow : Window { private ObservableCollection<Fruit> _fruits = new ObservableCollection<Fruit>(); public ObservableCollection<Fruit> Fruits { get { return _fruits; } } public MainWindow() { Fruits.Add(new Fruit { Name = "apple", Count = 3 }); Fruits.Add(new Fruit { Name = "orange", Count = 10 }); Fruits.Add(new Fruit { Name = "apple", Count = 3 }); Fruits.Add

WPF Datagrid group expander text - how to bind?

天涯浪子 提交于 2019-12-22 18:28:23
问题 I am using a datagrid with a combox that should change the grouping field. I am using the following xaml to define the general grouping template : <DataGrid.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type GroupItem}"> <Expander> <Expander.Header> <StackPanel Orientation="Horizontal"> <TextBlock Text="NEEDS TO BE BINDED..."/> </StackPanel> </Expander.Header>