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 2 years ago.
Improve this question
I want to create a WPF App in VS which should have various features (no serperate applications!).
The MainWindow should containt several Icon's (like App Icon's on Smartphone) which represents each of my features. So the MainWindow should be as an overview of my features. How do I need to realize it?
Which toolbar object represents an Icon? (Button?)
If I click on the Icon (Button?) the new feature should be showed as fullscreen (like on a Smartphone by clicking/starting an App). Which feature of WPF should I use to show the Page/Window of the Feature? If I close the feature the MainWindow should be showed again. I would be glad about a code example
Thanks
This question is likely too broad to get you the answers you are looking for, but a good place to start is with the Window class.
Once you create your buttons, you can spawn a new Window for your distinct feature. The Window.ShowDialog method will allow the new feature to remain active until it is closed. Setting the Window.Owner property will allow the new feature to return control to MainWindow.
I'd recommend trying some of these features out then coming back with specific questions you might have.
MainWindow.xaml
<Window x:class="MainWindow">
<!-- ... -->
<Button Click="Feature1_Click" Content="Open Feature 1"/>
<Button Click="Feature2_Click" Content="Open Feature 2"/>
<!-- ... -->
</Window>
MainWindow.xaml.cs
public class MainWindow : Window
{
//...
private void Feature1_Click(object sender, RoutedEventArgs e)
{
new Feature1Window
{
Owner = this
}.ShowDialog();
}
private void Feature2_Click(object sender, RoutedEventArgs e)
{
new Feature2Window
{
Owner = this
}.ShowDialog();
}
// ...
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I have created a currency converter app in Xamarin forms in which we have two Image controls that contain the country flags. Now, if the user clicks the swap button, the flags swap each other.
For example, the source of the first image will go to the second image, and vice versa.
<Image Source="usaflag.png" x:Name="Img1"/>
<Image Source="australiaflag.png" x:Name="Img2"/>
<Button Text="SWAP" x:Name="BtnSwap" Clicked="BtnSwap_OnClicked"/>
Here's my XAML Code. I know the we will write the swapping code in the code behind file. I am not using the MVVM style pattern so if you've any code regarding swapping then kindly share it with me.
Okay, so you want to swap two images in xamarin forms. Well, that's pretty simple!
You just need to add this code inside the OnClick() event of a button.
private void BtnSwap_OnClicked(object sender, EventArgs e)
{
var firstImage = Img1.Source;
var secondImage = Img2.Source;
Img2.Source = firstImage;
Img1.Source = secondImage;
}
In this case, you can Bind the sources and change those values on BtnSwap_OnClicked.
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
Specifically, I want to be able to launch my WPF (C#) application and then immediately be able to switch between two radio buttons using the arrow keys.
As it is, I need to use the Tab key or the mouse to "select" one of the radio buttons, and then I can start hopping between them using arrow keys.
Important note: I am not asking how to control which radio button is checked by default. I'm asking how to how to optimize keyboard user-friendliness of my WPF controls.
You can use the Focus () function to choose the item selected when the window opens.
public MainPage()
{
InitializeComponent();
Button1.Focus();
}
And you can define TabIndex orders to optimize the user experience.
In Xaml :
<Button x:Name="Button1" TabIndex="0"/>
<Button x:Name="Button2" TabIndex="1"/>
<Button x:Name="Button3" TabIndex="2"/>
Or in C# :
Button1.TabIndex = 0;
Button2.TabIndex = 1;
Button3.TabIndex = 2;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm making an app with the UWP and I need a way to detect the arrow keys.
I know that exist other methods like using " Window.Current.CoreWindow.CharacterReceived", but this one do'nt detect arrow keys. Some help pls?
Thanks
The solution depends on the view and the UI controls that it contains.
Basically, a UI Control has the KeyDown and KeyUp events to which you can subscribe and control the key that was pressed/released on the keyboard.
You need to keep track of the focused object on the view as depending on which one has it, the event handler may not be called:
By default, the first focusable element in the visual tree is given
focus by the system. An individual control gains focus when the user
clicks or taps directly on that control in the layout, or uses the Tab
key to step into a tab sequence within the content area. You can also
focus controls programmatically by calling Control.Focus.
So for example register to the Window's KeyDown event:
Xaml
<Window x:Class="WpfApplication25.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"
KeyDown="Window_KeyDown">
</Window>
CS
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_KeyDown(object sender, KeyEventArgs e)
{
// ... Test for F5 key.
if (e.Key == Key.F5)
{
this.Title = "You pressed F5";
}
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am doing a school project and i canĀ“t figure out how to "hide" some text blocks when the toggle switch is on and the opposite? Developing a windows 8 app. Thanks and btw. How do you make a collection from multiple text blocks(XAML)?
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
}
Assuming your control structure is fairly flat, you can get by using the Tag property on the TextBox. In your XAML, put some distinct value in the Tag field for each TextBox you want to make toggle-able, like the word 'CanToggle'. Then you can do something like
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
foreach (Control currentControl in this.Children)
{
if (currentControl.Tag == "CanToggle")
currentControl.Visible = !currentControl.Visible;
}
}
If your control collection is not flat, then you'll have to figure out how to dig recursively through the collection of controls to locate all the TextBox that you want to toggle. This answer may help.
Visual Studio Main Menu - Edit - Outlining - Toggle All Outlining: Ctrl+M, Ctrl+L
Personally, I use Ctrl+M to "collapse to defininitions" more than anything else though.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Please can you help me how can i create popup panel with informations for mouseover. I using C# offline application.
I don't know how can i do this on mouseover with application. For website it is javascript but for C# ... i don't know.
I know how to use mouseover for it, but i don't know how to create popup window with informations for mouseover. It's exactly my problem. Please can you help me?
You could start by testing the following:
You can use MouseEnter to show a window in a popup style.
private void panel1_MouseEnter(object sender, System.EventArgs e)
{
MyForm frm = new MyForm();
frm.ShowDialog();
}
When you require behavior like jquery UI Tooltip you can use UserControl
private Control popup;
private void panel1_MouseEnter(object sender, System.EventArgs e)
{
MyUserControl mcu = new MyUserControl ();
this.popup =mcu; //save references to new control
this.Controls.Add(this.popup);
this.popup.Location.X = ((Control)sender).Location.X+ offsetX;
this.popup.Location.Y = ((Control)sender).Location.Y+ offsetY;
}
private void panel1_MouseLeave(object sender, System.EventArgs e)
{
this.Controls.Remove(this.popup);
}
This sounds suspiciously like a ToolTip.
So I recommend that you use the ToolTipService for this (in your xaml):
<object>
<ToolTipService.ToolTip>
<objectThatFillsTheToolTip .../>
</ToolTipService.ToolTip>
</object>
This sample is from the msdn docu page.