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>
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 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 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.
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.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am trying to achieve an effect of overlapping the main window boundary with a control. It's hard to explain this in words which is also maybe why I am having difficulty finding information on how to do this or if it is even possible.
Below is an example of the effect I am trying to get (from the designer), where the "note" objects float outside the bounds of the main window.
However the effect I get at runtime is this (below), the inner controls are clipped by the boundary of the main window.
Can someone please tell me if this is possible (or not), and if it is maybe some suggestions about how I could get this effect.
There is a control that can achieve this kind a behavior have you tried a Popup control?
Check this out
Here's an examp;e"
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ToggleButton x:Name="MainButton" Content="Show popup" VerticalAlignment="Top" HorizontalAlignment="Right"/>
<Popup PlacementTarget="{Binding ElementName=MainButton}" Placement="Bottom" AllowsTransparency="True" IsOpen="{Binding ElementName=MainButton, Path=IsChecked}">
<Grid>
<Border BorderBrush="Orange" BorderThickness="1" Background="Yellow"/>
<TextBlock Text="Lorem Ipsum is simply dummy text of the printing and typesetting industry"/>
</Grid>
</Popup>
</Grid>
Contents of window will always get clipped. So basically there is only one way to go here. You could get the desired effect by creating a new transparent window for your floating content and then manualy set and update the position of floating content window based on the location of main window.
So far I've been using AvalonDock for similar functionalty. You might give it a try...
I don't think there's a way to draw outside the bounds of a window. However, you could simply create a new window for the note control and align it to your main window.
Did you try ClipToBounds property?