I want to remove the spaces between the blocks showing the progress.
I need it to be solid.
Code:
<ProgressBar Name="probar" Minimum="0" Height="40" BorderThickness="0"/>
Geetha
You need to redefine the template of the ProgressBar. Fortunately, it's not very complex... The simplest way is to extract the template with a tool like Style Snooper, the BAML Viewer Reflector Add-in, or Show Me The Template, and change the part that defines the background.
Related
I want to change the graphical UI elements in WPF.
For example, I want to use a kind of a stack panel, but on the other hand I want to show my details in a star, or circle, etc.
Maybe setting a bitmap as a background, but I am working with lots of Data using zoom tool.
I found tutorials, documentation only for changing attributes of "old components", but nothing to make new ones.
Great resource for WPF beginners is www.wpftutorial.net
One of the best idea of WPF is separation of concerns:
UI Control = Logic in Code/XAML + Template
Using templates in XAML we can vary representation without modifying the control.
For example, if there is a need in creation of list of items. Then we can use ListBox control:
<ListBox>
<ListBoxItem>USA</ListBoxItem>
<ListBoxItem>UK</ListBoxItem>
</ListBox>
By default LisboxItem internal part is just binded TextBlock.
Now making UI modification without changing control source code:
<ListBox ImageSource="{Binding PathToSource}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{StaticResource ProjectIcon}"/>
<TextBlock Text="{Binding Path=PropertyName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
there appears image and text.
If there is a need in creating exclusive control then you can always use Custom Control.
Using raster images (e.g. PNG) is not good point, especially with zoom behaviour. If it is possible better to use vector images, that can be created in XAML or imported from SVG.
i want use to ShowDuration attribute in a tooltip at silverlight project. but ShowDuration not exist in ToolTip control
for example:
<Button x:Name="btnAppUserRoleAdd" Style="{StaticResource GlassButton}" Content="button" Width="100" Height="36" Margin="0 0 40 0">
<ToolTipService.ToolTip>
<ToolTip ShowDuration="10000" Template="{StaticResource ToolTipTemplate}" HorizontalOffset="2" VerticalOffset="5">
<ToolTip.Content>
<TextBlock Text="any test"
TextWrapping="Wrap" Style="{StaticResource ButtonTooltipFontStyle}" />
</ToolTip.Content>
</ToolTip>
</ToolTipService.ToolTip>
"ShowDuration="10000" this attribute have not known by intellisence in VS2010 and that say: cannot resolve symbol ShowDuration
my tooltip without ShowDuration working properly and not problem. but i want use this attribute. of course, i use tooltip class in code (c#) but problem not solved.
please help me
i use silverlight4, visual studio 2010.
The Silverlight implementation of a ToolTip does not have a ShowDuration property.
The referenced Tooltip opensource lib has big problem when use with Silverlight DataGrid control, it open many tooltips which are not closed when mouse moved away, it can open many of the same tooltips if you you move mouse arround in a cell. We are forced to take it out from project. We are still looking for a solution just to extend the display duration of tooltips.
Here is a Advanced Silverlight Tooltip Control. This Tooltip has the DisplayTime property. Maybe it is helpful.
You have to download the dll file and reference it.
Silverlight tooltips currently don't have the extended functionality that WPF provide to set delay or duration.
As much as I'd like to see this functionality baked into Silverlight, I've had to build something myself. This also meant I had to create my own ToolTipService as lots of the code I needed to hook into was internal.
Replace your references to ToolTipService and ToolTip to the ones in the library and you'll get more properties to exploit :-)
You can find it on Codeplex as well as on NuGet.
Hope that helps!
Cheers,
Xavier
I want to initiate a bound command, but I don't want to use a Button on my UserControl. In effect the UserControl is itself a Button. When it is clicked anywhere on its surface I want to initiate a bound command. Is there a way to give a UserControl a command?
In a side note: one command for one control and only a few certain out-of-the-box controls? This all seems a little clunky. I'm starting to think that MVVM is impractical. I can decouple my UI just fine with Interfaces and OOP. Anyway, I still have hope.
Also, I'm not willing to hack anything or use an expensive workaround. If I can't do this, I'm abandoning MVVM.
Take a look at the ICommandSource interface here: http://msdn.microsoft.com/en-us/library/system.windows.input.icommandsource.aspx. If you want a control to have a command, then your control should implement this interface. Examples of controls that implement this interface are ButtonBase and MenuItem. Hope this helps.
If your UserControl is essentially a Button, why are you writing your own UserControl instead of using the Button class?
To add more info, here's what you do:
Subclass Button, put any extra DependencyProperties that you need in there - it should be a very empty class (you could even have something like public class MyCoolButton : Button { }
Add a Style whose TargetType is MyCoolButton - don't name the style so it applies to all MyCoolButtons
Override the default Template of the style, then paste in your Xaml code. You might have to do some work here to handle the "Normal / Pushed / Disabled" states. If you're using v4.0, you can use VSM here.
I will agree with Paul Betts.
Quite often I create my own ListBoxItemContainerStyle using a button as the top container with nothing but a propertyless content presenter in it. This allows me to use the buttons functionality (like Command) without having the Windows chrome on it.
Putting it in the ListBoxItemContainerStyle also lets me make it so that when it is clicked it does not display the normal dotted border (FocusVisualStyle={x:Null}).
Are you using Visual Studio or Expression Blend to do your styling?
Additionally, some MVVM frameworks provide an interface for adding a command-ish ability to controls other than buttons. Caliburn has a pretty rich command pattern. I am not sure if it allows binding commands on non-button controls, however.
The OP asked for an example of how you could use a button control, but with the content properly filling the entire button. You can do this using the ContentAlignment properties:
<Button HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Button.Content>
<Grid IsHitTestVisible="False">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Row0" />
<TextBlock Grid.Row="1" Text="Row1" />
</Grid>
</Button.Content>
</Button>
This creates a button with two labels spaced using a Grid control. I mark the Grid to turn off HitTestVisible, as you have to decide which controls should interact like the button and which should interact like controls. For instance, you might have an embedded TextBox that you want to be clickable without clicking the button, in which case it should have HitTestVisible=True.
WPF supports layers and transparency :
Panel.ZIndex
You can create anything that supports commanding on a superior transparent layer, the size you want, to act as a button.
I'm using a Bar Chart in the system.windows.controls.datavisualization.toolkit in a WPF/C# project. I would like to print this chart on a page, but it appears none of the binding are executed before printing. I end up with an empty square where the chart should be.
My XAML code looks like this (I've ommitted layout things)
<Grid x:Name="LayoutRoot">
<chartingToolkit:Chart x:Name="GUIchart" Style="{StaticResource TheGUIChartStyle}" FontSize="12">
<chartingToolkit:BarSeries x:Name="Series" ItemsSource="{Binding}">
<chartingToolkit:BarSeries.DependentRangeAxis>
<chartingToolkit:LinearAxis x:Name="Xaxis" Minimum="0" Maximum="100" Interval="10" ShowGridLines="True" Orientation="X"/>
</chartingToolkit:BarSeries.DependentRangeAxis>
</chartingToolkit:BarSeries>
</chartingToolkit:Chart>
</Grid>
In c# I'm adding some titels and the bindings:
// set the X-axis title
Xaxis.Title = "Score in %";
// do the binding
Series.IndependentValuePath = "Name";
Series.DependentValuePath = "Score";
Series.ItemsSource = scores;
When debugging, this binding is actually executed before the chart is being add to the page. Nevertheless, I end up with an "empty" chart.
One possible cause for this the default fade-in animation in the chart. It is described in this forum post. You should be able to copy the default chart style from the source code and comment out the VSM animation.
You can download the source code for the latest DataVisualization development release here. Once you have the source, the file you want to look at is in the Core.WPF project - Themes\Generic.xaml. All the styles can be found there.
I have not actually tried it, but you should be able to copy the BarDataPoint style and remove the "RevealStates" VisualStateGroup.
What I'd like is a control that functions just like the tab control but instead of having the tabs along the top, the items would be displayed in a list box along the side. I imagine it's possible but haven't found any examples, I'm hoping there's someone here that's done something like this.
WPF controls are designed to enable exactly what you want. To reuse control functionality while completely replacing the visual representation. You will have to create your own ControlTemplate for the TabControl. You can find a TabControl ControlTemplate Example on MSDN. You will also have to study the Control Authoring Overview on MSDN.
I actually find the Silverlight 3 documentation somewhat easier to digest, and even though there are some differences when it comes to control styling the fundamental concepts are still the same. You can read Customizing the Appearance of an Existing Control by Using a ControlTemplate on MSDN to learn about control templates and then study TabControl Styles and Templates to discover what is required to create you own control template in Silverlight.
You can use Expression Blend to extract the the default TabControl template in WPF.
You don't need to use a TabControl at all. You could just bind your ListBox to a list of items, and put a ContentControl beside it, bound to the selected item :
<DockPanel>
<ListBox Name="listBox"
DockPanel.Dock="Left"
ItemsSource="{Binding Items}"
DisplayMemberPath="Name"/>
<ContentControl Content="{Binding SelectedItem, ElementName=listBox}"
ContentTemplate="{StaticResource theTemplate}"/>
</DockPanel>