Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wanted to make Header User Control that should be available on the top of all the pages in windows phone 8 app.I don't want to declare this control on all the pages and also its functionality will going to be same on different pages.
It would be like Application bar. So, where should i have to declare or define this control such that above mentioned goals can be fulfilled ?
Great. In this case you can create a custom user control. Create your bar with all necessary things (buttons, images etc).
Add all handlers in this user control itself. Now that you have this control ready. You can just add this control like any other control onto a xaml page where you wish to have it. It will just require your namespace to be present in the xaml.
eg:
xmlns:animateMenu="clr-namespace:AppNameSpace.Presentation"
This namespace once added will let you access your user control everywhere.
using it this way:
<animateMenu:Menu x:Name="MyMenu"/>
EDIT
Code to place in app.xaml
<shell:ApplicationBar x:Key="CommonAppBar" IsVisible="True">
<shell:ApplicationBarIconButton IconUri="/Resources/Images/Appbar.btn1.png" Text="home" x:Name="abibtnHome" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/Resources/Images/Appbar.btn2.png" Text="search" x:Name="abibtnSearch" Click="ApplicationBarIconButton_Click"/>
<shell:ApplicationBarIconButton IconUri="/Resources/Images/Appbar.btn3.png" Text="call" x:Name="abibtnCall" Click="ApplicationBarIconButton_Click"/>
<!-- added for menus in the app bar-->
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="menuitemSettings" Text="menu1" Click="menu1_Click"/>
<shell:ApplicationBarMenuItem x:Name="menuitemAbout" Text="menu2" Click="menu2_Click"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
Hope this helps.
Thanks and Cheers.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am attempting to use the materialDesignInXaml StaticResource MaterialDesignOutlinedTextBox. I have an issue where say, I want an not selected textBox to be Blue, and when i select the textbox, it appears to turn green.
From comment below, i was able to get the selected textbox border brush to turn green using, materialDesign:TextFieldAssist.UnderlineBrush. However, i do not know how to control the borderbrush color when it is unselected to turn to blue. Default is black but I am unable to figure out where this color is set.
There are two different brushes involved. One is used for the underline color on hovering and the other is used in case the value is proved invalid through validation. The normal underline can be changed through the TextFieldAssist.UnderlineBrush attached property on the TextBox.
<TextBox materialDesign:TextFieldAssist.UnderlineBrush="Green">
The validation brush called MaterialDesignValidationErrorBrush (red by default) is referenced in the control template for TextBox using a DynamicResource, so you can override it in the local resources (or application if you want) without needing to copy or change the control template.
<TextBox>
<TextBox.Resources>
<SolidColorBrush x:Key="MaterialDesignValidationErrorBrush" Color="Green"/>
</TextBox.Resources>
<!-- ...other markup. -->
</TextBox>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a WPF combobox (From the toolbox) that I'm trying to edit.
The created combobox can be filtered by clicking into it and typing what you want.
How does a combobox know (What event gets triggered or element get activated or ...) if your clicking on the arrow or the textbox.
Bonus: Using styles can you change the ratio of the combobox that you can click for the textbox vs the dropdown arrow?
The default ComboBox has a default styling which determines the size of the text box and the drop down arrow. Like other controls in WPF, you can edit the control template of the ComboBoxto change the appearance and size of those items. If you look at this question you can see examples of overriding the default styling. What you are interested in is the size of the column definitions:
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm trying to create a WPF application where the homepage (aka MainWindow) will contain several tabs.
I'm wondering what would be the best approach/architecture to encapsulate code specific to each tab instead of coding everything in the same place ?
NOTE
After some research I found UserControl class, but I've always thought that class was use in order to avoid re-coding the same logic over and over. In my case I would be using them once for every tab.
Depending on your preference and desired level of complexity, you can use MVVM or just create a UserControl for every tab to better distribute the code. Resulting in your window's xaml looking something like:
<TabItem x:Name="tab_peerView" Header="Peers (Lobby)" Visibility="Visible">
<Views:SomeUserControl1 />
</TabItem>
<TabItem x:Name="tab_PrepCheckList" Header="Prep" Visibility="Visible">
<Views:SomeUserControl2 x:Name="view_prep" />
</TabItem>
Doing this method you can also offload things like command bindings and respective Execute and CanExecute to the UserControls.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've been trying to make a program, that makes an ellipse move on the screen (by the arrow keys), when I am still able to click the window that is open behind it (for example - Google Chrome) and the ellipse will still be visible and move-able.
I've been trying a lot of things (including TopMost) and nothing worked.
Now, my idea is to make a transparent window, that is un-clickable and will re-open (will be maximized) every time it gets minimized.
Can someone please help me? I have no code that can help, the names of the objects involved don't matter.
I think your questions are already answered elsewhere:
Click-through control in WPF (use <TextBlock IsHitTestVisible="False" .../>)
Preveting the window from minimizing:
a. Cancel minimizing event (intercept the minimize event and cancel it)
b. Preventing from minimizing on "Show Desktop" (Win+D) command (mark the window always-on-top)
I am not sure if I understood your question right, you want to click through the ellipse.
You could for example just use two grids with different ZIndex and just Register when 1 gets clicked. Eg:
<Grid>
<Grid Background="Transparent" Panel.ZIndex="1">
</Grid>
<Grid Panel.ZIndex="0">
<Ellipse Background="Blue" Height="100" Width="200"/>
</Grid>
</Grid>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
<ContentControl Width="130"
Height="130"
Canvas.Top="60"
Canvas.Left="50"
***Selector.IsSelected="True"***
Style="{StaticResource DesignerItemStyle}">
I would like to set property Selector.IsSelected to ContentControl by using code behind. But I don't know how to do it. Please help me and give me some example.
If you want to set an attached dependency property in code you do this
ContentControl x;
//To set the value
x.SetValue(Selector.IsSelectedProperty, true);
//To Clear the value
x.ClearValue(Selector.IsSelectedProperty);
//Set using the static function on Selector
Selector.SetIsSelected(x, true);
For accessing a control in Code-behind you need first provide it a name -
<ContentControl
x:Name=""ContentControl1"
Width="130"
Height="130"
Canvas.Top="60"
Canvas.Left="50"
***Selector.IsSelected="True"***
Style="{StaticResource DesignerItemStyle}">
and then you can access it in code and set the value as mentioned in other answer -
ContentControl1.SetValue(Selector.IsSelectedProperty, true);
Apart from this it would be a good idea to look at creating a property in code-behind or ViewModel(MVVM) and bind that directly to your control like this -
<ContentControl
Width="130"
Height="130"
Canvas.Top="60"
Canvas.Left="50"
Selector.IsSelected="{Binding IsSelectedBoolProperty, Mode=OneWay}"
Style="{StaticResource DesignerItemStyle}">
This techniques will be very useful in case you have a lot of controls in your window and I would suggest you to look at implementing MVVM in your application to avoind doing these kind of things in code-behind.