wpf-controls

Validation Rule for Radio buttons wpf

孤街浪徒 提交于 2019-12-20 05:22:06
问题 I have a RadioButton inside ItemsControl . By default Radio Buttons will be unchecked. I want the user to select either of the radio buttons if a particular value (string value) is configured in another screen. I need to apply a validation rule for the same. If the user does not select either of the radio buttons, then on click on a submit button, I should display validation error. XAML <StackPanel Grid.Row="1" Visibility="{Binding Path=IsUpdateSendDateConfigured}" Orientation="Horizontal"

How do I add UI Children to an empty WPF-Page?

此生再无相见时 提交于 2019-12-20 05:10:32
问题 I'm having a MainWindow which is a NavigationWindow. Inside this MainWindow I want to switch in several Pages. One of the Pages has to be dynamically generated by Code, not by XAML. When I had a normal window before, I could add UI components like this: Button b = new Button(); b.Content = "Hello"; this.AddChild(b); Or if I added (for example) a StackPanel with this method first, I could add Children to this StackPanel with: myPanel.Children.Add(b); However, the Page Class doesn't have a

Setting font of parent in nodes in WPF Tree View to Bold using code behind

一个人想着一个人 提交于 2019-12-20 04:52:51
问题 I have made a tree view and added parent and child nodes to it all using code behind, now where I am stuck is to set the font of parent nodes to BOLD while keeping the font of child as it is, below is code that i have right now. List<ParentTreeViewNode> ParentTreeViewNodeList = new List<ParentTreeViewNode>(); HierarchicalDataTemplate treeViewTemplate = new HierarchicalDataTemplate(typeof(Child)); treeViewTemplate.DataType = "{x:Type local:Child}"; treeViewTemplate.ItemsSource = new Binding(

How to set object who pass to template, as binding?

主宰稳场 提交于 2019-12-20 04:38:17
问题 I have DataTemplate: <DataTemplate DataType="{x:Type PointCollection}"> <Polygon Stroke="Blue" Points="{Binding}"Fill="White"/> </DataTemplate> and I need to put PointCollection in Points property of Polygon. What syntax for this? I use CompositeCollection as ItemsSource, which contains objects of different types, so, I can't just bind some property of my Model. 回答1: Here is an example which uses a ListBox to hold the points collections. <Grid> <Grid.Resources> <DataTemplate DataType="{x:Type

Saving the State of a WPF Application Page

浪尽此生 提交于 2019-12-20 04:22:35
问题 I am creating a software in WPF, and, in the software, the User can load an image, and configure a map. Basically, once the Image (of a map) is loaded the user can add other images (like a picture of a treasure or a monster, etc) drag and drop them within the image of the Map. When the user closes the software, and reopens it, I want the last image opened, and the UI elements added to be in the same place, like how the User had set up, before closing the application. One way I can think of,

Image.Height TemplateBinding does not work

99封情书 提交于 2019-12-20 03:54:29
问题 I have created a CustomControl implemented from Button class in WPF. public class ImageButton : Button { ... public int ImageHeight { get { return (int)GetValue(ImageHeightProperty); } set { SetValue(ImageHeightProperty, value); } } public static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register("ImageHeight", typeof(int), typeof(ImageButton), new UIPropertyMetadata(32)); ... } And I have resource template like this: <Setter Property="Template"> <Setter.Value>

WPF ComboBox not responding to mouse

别说谁变了你拦得住时间么 提交于 2019-12-20 03:13:52
问题 I have a very weird problem with a WPF ComboBox. On one computer (and only one) in our company the WPF ComboBox refuses to respond to mouse events when the ComboBox drop down is open. When the user clicks on the ComboBox to make the drop down appear and tries to select an item, he/she gets no hover effects from mouse over. When the user clicks on an item, the drop down closes, but the item they clicked never gets selected. It seems like the ComboBox's drop down of items is not responding to

Easiest way to get the angle of mouse position in WPF relative to the center of a circle

大城市里の小女人 提交于 2019-12-20 03:07:36
问题 I have a circle when mousemove I can get e.GetPosition(this). But how to programmatically get the angle relative to the center of the circle ? I saw on the internet some sample clocks with binding in XAML. That's not what I want, I want to get the angle value from mouse position relative to the center of a circle. This is what I tried: private void ellipse1_MouseMove(object sender, MouseEventArgs e) { Point position = e.GetPosition(this); double x = position.X; double y = position.Y; double

UserControl Location in WPF

*爱你&永不变心* 提交于 2019-12-20 02:30:34
问题 I am new in WPF, I created a new UserControl MyUserControl. Now I am surprised: the UserContol does not have a location. How can I read (by code) myUserControl1. Location in the parent container? I explain: I have some Dots (UserControls) that the user can drag in a panel. Actually, I am not sure what kind of Panel this will be... Perhaps Grid. Now, these dots should be linked with a Line. Actually, I have a Dot.Head and Dot.Queue properties (also Dots). So, when a Head or Queue is added, I

How to inherit Button behaviour in WPF style?

穿精又带淫゛_ 提交于 2019-12-20 02:26:11
问题 I have overriden the WPF default Maximize, Minimize buttons like explained here. But, in my case, instead of using an Image to override background image for that buttons, I wanted to add my own template. So I created a ResourceDictionary that applies a style for Maximize/Minimize/Restore/Close buttons. The thing is that I override the template. As an example, see the PART_MINIMIZE button: <Button x:Name="PART_MINIMIZE" Width="30" Height="20" Margin="0,0,4,0" HorizontalAlignment="Center"