I want to know how to add additional button to Form ControlBox that is present at image below:
I know in this forum are few similar questions but no single one answered my question. I checked few links and its not that what i expected because its not working at every operating system. I checked those links:
http://www.codeproject.com/Articles/11510/Add-Transparent-Menus-and-XP-Titlebar-Buttons-to-y
http://www.codeproject.com/Articles/10171/Adding-a-Minimize-to-tray-button-to-a-Form-s-capti
Other idea is to change default click event and icon for MaximizeBox because i don't need this one in my app.
Scratch this - just realized it's a Winforms issue.
Kinda lame suggestion, but in WPF I'd do:
Drop the title
<Window> ... WindowStyle="None" ... /<Window>
Then roll my own:
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
<Button HorizontalAlignment="Right" Width="25" Content="Yo!"/>
<Button HorizontalAlignment="Right" Width="20" Content="-"/>
<Button HorizontalAlignment="Right" Width="20" Content="■"/>
<Button HorizontalAlignment="Right" Width="20" Content="X"/>
</StackPanel>
Caveats:
You will have to do a mouse capture to move the window, not difficult but not trivial either. Also change the style of the buttons to look like the regular icons etc
Not ideal I know, but in a pinch ...
Related
So every time i add images to a button this effect happens, usually when brushing over the button.
i assume it has something to do with the default button mouse over effect but so far i've had no luck with changing the default style and this effect keeps happening. is this just wpf being wpf or something that shouldn't usually happen.
Button before mousing over/ brushing over:
Wrongly displayed button:
<Button Grid.Row="5" Grid.Column="0" x:Name="savebutton" HorizontalAlignment="Center" Click="savebutton_Click">
<Button.Content>
<Image Source="Images/folder.png" Width="40" Height="40" />
</Button.Content>
</Button>
I am not sure they correct terminology for a header/title bar of a component in WPF. What I need is a panel/non-floating window, in which I can set the title? I want a few components in a panel that needs a title like Properties and Toolbox in Visual Studio.
As mentioned earlier, this doesn't need to be a floating/docking panel. I don't want GroupBox. I will be adding close button later just to hide the component from the user.
I think, that in WPF visual solutions are limited only by our imagination.
If there isn't the control you want - you can build it.
My simple solution is here:
<Border Visibility="Visible" BorderThickness="2" BorderBrush="Blue" CornerRadius="8" Margin="30,30,30,30">
<StackPanel Margin="3">
<Label Height="25" Content="H e a d e r" Background="LightSkyBlue" />
<Separator Height="5"/>
<Grid>
<!-- content -->
</Grid>
</StackPanel>
</Border>
Changing Visibility="Collapsed" you can hide this "panel".
If you don't need it to undock and float then you can use a HeaderedContentControl.
When you want to add the close button you can template the header presenter to include a button.
I've got 2 buttons on my form, and they both look very, very flat.
I can't seem to find a way to make them look more like:
The XAML for my buttons is:
<Button x:Name="bttnDailyReport" HorizontalAlignment="Left" Margin="618,27,0,0" VerticalAlignment="Top" Width="121" Height="93" FontFamily="Microsoft Sans Serif" FontSize="20" FontWeight="Bold" Grid.Column="1" BorderBrush="Black">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"><Run Text=" Generate"/><LineBreak/><Run Text="Daily Report"/></TextBlock>
</Button>
<Button x:Name="bttnCancel" HorizontalAlignment="Left" Margin="618,126,0,0" VerticalAlignment="Top" Width="121" Height="93" FontFamily="Microsoft Sans Serif" FontSize="20" FontWeight="Bold" Click="BttnCancelClick">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"><Run Text="Exit"/></TextBlock>
</Button>
Now, my question is, is it possible to make the buttons appear like the button in WinForms, or am I stuck with flat buttons?
Seems, somewhere in your resources, flat button style is used as default style for button.
Check Styling and Templating. Either you need to override the style in your button, or give key to the default style, and apply wherever needed.
How to override a global style (that doesn't have an x:Key), or alternatively apply a named style to all type-targeted controls?
Just reference PresentationFramework.Aero.dll in your project and add this code to to the window's XAML:
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;component/themes/aero.normalcolor.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
By default, buttons should look like the second image. To make sure that there is no "BoringButton" Style around that make your buttons look flat (as Tilak and Chris W suggest), try to explicitly clear your button's Style like this:
<Button x:Name="bttnDailyReport" Style="{x:Null}" >
Also, don't set your button's Background to a specific color (although that already looks OK in the code you posted).
I'm supposed to make a user-control using WPF, and now i'm bumping into a weird problem.
I came up with a kinda weird solution to get an image along with some text in a button, like this:
<Button Height="24" Width="100" Name="btn_change">
<StackPanel Width="90">
<Image Source="Images\11.png" Width="24" Height="18" HorizontalAlignment="Left" Panel.ZIndex="-1" Stretch="Uniform"></Image>
<Label Content="Change" HorizontalAlignment="Right" Margin="0,-18,0,0" Height="20" Padding="0,0,0,0" />
</StackPanel>
</Button>
This worked perfectly, until i started using a MVVM Framework (Caliburn.Micro). From that point on the images no longer show up in the buttons, just the text. I can't figure out why it doesn't work.
Maybe someone with knowledge of MVVM Frameworks can explain this or give me a solution :)
Thanks in advance!
EDIT:
Never mind! I looked it over thanks to H.B. and it seemed I moved the View to a subfolder. I changed the image source from "Images\11.png" to "..\Images\11.png" and it worked!
Just change your image source from "Images\11.png" to "..\Images\11.png" and it will work.
Hello and thanks for the help. I have a Treeview that I am populating with a Hierarchical data template, and currently the bottom nodes have a tooltip that generates a small stack panel that is populated with data specific to the item the mouse hovers over. I also have a button sitting in the tooltip, however, as the tooltip does not persist when the mouse moves over it, I am unable to make use of the button like I need to. My xaml looks like this:
<!--=========================== Hierarchical Data template for tree view -->
<!--template for bottom nodes-->
<sdk:HierarchicalDataTemplate x:Key="ModTemplate" ItemsSource="{Binding ApplicationModules}">
<StackPanel Orientation="Horizontal" > <!--======tooltip style to handle format for callout window============-->
<ToolTipService.ToolTip>
<ToolTip HorizontalOffset="0" VerticalOffset="0" Style="{StaticResource ModuleToolTipStyle}">
<StackPanel Width="150" Height="auto" >
<TextBlock Text="Module Info" FontWeight="Bold" TextAlignment="Center"/>
<TextBlock Text="Module State:" FontWeight="Bold" />
<TextBlock Text="{Binding Path=ModInfo.ModuleState}" />
<TextBlock Text="Module Start Time:" FontWeight="Bold" />
<TextBlock Text="{Binding Path=ModInfo.ModuleStartTime}"/>
<TextBlock Text="Module Down Time:" FontWeight="Bold"/>
<TextBlock Text="{Binding Path=ModInfo.ModuleDownTime}" />
<Button Content="More Info" Width="75"></Button>
</StackPanel>
</ToolTip>
</ToolTipService.ToolTip>
<!--============end tooltip style for callout window===================-->
<ContentPresenter Margin="0 0 4 0" Content="{Binding Icon}" />
<TextBlock FontStyle="Italic" Text="{Binding Path=ModuleName}" />
</StackPanel>
</sdk:HierarchicalDataTemplate>
I would like the tooltip to persist when the mouse moves over it so that I can wire an event to the button. How can I achieve this? Thanks again for the help.
You have a couple options to accomplish your goal that I'm aware of. You can go check out the Silverlight Advanced Tooltips project over on codeplex which does what you want (though I personally have not used it so can't give any kind of review.)
Or you can make your own with some creativity. If it were me I would probably skip all that mess, forget the ToolTipService all together and just make my own to dress it up since to a user, what you're providing isn't what they're used to in terms of a tooltip expectation anyway and have cross more over to a callout or popout functionality. I can make an example as soon as I get some freed up time if option #1 doesn't work for you but I hope it does. Essentially both my way, and that project link I provided would do the same thing, which is provide a delay after the MouseLeave event of what it's attached to so the user can get to it before it disappears. Then hand off its visibility condition to that object. Let me know if this doesnt work and I can give you an alternative example using nothing but XAML.