custom-controls

wpf keep base style in custom control

梦想的初衷 提交于 2020-06-27 16:47:08
问题 I have created a custom button as i wanted an image and a text inside it as follows: <Style TargetType="{x:Type Local:ImageButton}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Local:ImageButton}"> <StackPanel Height="Auto" Orientation="Horizontal"> <Image Margin="0,0,3,0" Source="{TemplateBinding ImageSource}"/> <TextBlock Text="{TemplateBinding Content}" /> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> Here, ImageButton is a class

WPF “hex grid” component

本小妞迷上赌 提交于 2020-06-11 05:50:33
问题 Jumping into the world of WPF custom controls, and was wondering what the best way to design a HexGrid control would be? Think your favorite table-top war game; or, equally likely, your favorite video game that steals the design from a proud history of table-top war games. The underlying model exposes one significant method, as a part of a Map class: Hex GetHex(int x, int y, int z)*; Hex contains all relevant data (at the moment, a Terrain enumeration that maps 1:1 to a background color;

How to get instance of Panel that holds content of ItemsControl?

痞子三分冷 提交于 2020-05-12 11:12:22
问题 Every ItemsControl has its content stored in Panel right ? We can specify the panel to be used in XAML like this: <ListView Name="LView"> <ListView.ItemsPanel> <ItemsPanelTemplate > <StackPanel/> </ItemsPanelTemplate> </ListView.ItemsPanel> </ListView> My question is how to get instance of Panel that is used in the ItemsPanel property (of type ItemsPanelTemplate ) of the particular ItemsControl ? For example ListView called LView from above code sample? I cannot use Name property or x:Name ,

How to get instance of Panel that holds content of ItemsControl?

时光总嘲笑我的痴心妄想 提交于 2020-05-12 11:09:11
问题 Every ItemsControl has its content stored in Panel right ? We can specify the panel to be used in XAML like this: <ListView Name="LView"> <ListView.ItemsPanel> <ItemsPanelTemplate > <StackPanel/> </ItemsPanelTemplate> </ListView.ItemsPanel> </ListView> My question is how to get instance of Panel that is used in the ItemsPanel property (of type ItemsPanelTemplate ) of the particular ItemsControl ? For example ListView called LView from above code sample? I cannot use Name property or x:Name ,

How to get instance of Panel that holds content of ItemsControl?

喜欢而已 提交于 2020-05-12 11:08:32
问题 Every ItemsControl has its content stored in Panel right ? We can specify the panel to be used in XAML like this: <ListView Name="LView"> <ListView.ItemsPanel> <ItemsPanelTemplate > <StackPanel/> </ItemsPanelTemplate> </ListView.ItemsPanel> </ListView> My question is how to get instance of Panel that is used in the ItemsPanel property (of type ItemsPanelTemplate ) of the particular ItemsControl ? For example ListView called LView from above code sample? I cannot use Name property or x:Name ,

Xamarin Forms - Get custom control runtime (with valueconverter?)

旧时模样 提交于 2020-05-09 17:21:26
问题 I have a Xamarin forms application. It has a page. That page has a listview. The listviews is bind to a sourcelist. What I want is to decide what custom control to use based on a specific property that each item in the list has. How can I achieve this? It is also required that the custom control binds to values from the list. I tried the following: <ContentView Content="{Binding IsPriority, Converter={StaticResource RoadIndicatorBackgroundValueConverter}}" ControlText="{Binding TowingOrder

Moving frameless window by dragging it from a portion of client area

我们两清 提交于 2020-04-11 04:21:13
问题 As the title says, I would like to move the window only when the user will drag it from a portion of the client area. This will be an imitation of the normal caption bar movement and it's because my form is custom and it doesn't have any title or caption bars. At the moment, I use the code as follows: ... case WM_NCHITTEST: return HTCAPTION; and that works fine for making the user able to move the window no matter where he drags from. I would like to limit this possibility (only the top of

Moving frameless window by dragging it from a portion of client area

∥☆過路亽.° 提交于 2020-04-11 04:21:07
问题 As the title says, I would like to move the window only when the user will drag it from a portion of the client area. This will be an imitation of the normal caption bar movement and it's because my form is custom and it doesn't have any title or caption bars. At the moment, I use the code as follows: ... case WM_NCHITTEST: return HTCAPTION; and that works fine for making the user able to move the window no matter where he drags from. I would like to limit this possibility (only the top of

Highlight Search TextBlock

心已入冬 提交于 2020-03-18 15:38:57
问题 My goal is to create a custom TextBlock control that has a new dependency property, SearchText. This property will contain a regular expression. All occurrences of this regular expression in the text of the TextBlock will be highlighted using a custom style (another DP). My current implementation involves clearing all of the Inline objects in the TextBlock's InlineCollection. I then fill the TextBlock with runs for unhighlighted text and runs for highlighted text with the style applied (this

Generate code or events when drag-drop a custom control from the toolbox

耗尽温柔 提交于 2020-03-03 10:15:09
问题 I'm creating a custom control (e.g custom LookUpEdit) and I'm wondering if I can generate code (e.g EditValueChanged event in form.cs file or some rows of code e.g in Form_Load event) automatically while I drag and drop this control inside a form designer, giving this way to any developer the opportunity to easily see and extend this code if he/she wants. My question is: How to generate code or events automatically in a form (form.cs) when you drag-drop a custom control from the toolbox at