|
Or, like John said, write a value converter...
1) Create a class that inherits from IValueConverter
2) Implement the Convert function such that it returns Visibility.Collapsed for 0, or Visibility.Visible for anything else.
3) Create an instance of that class in your resources section in the XAML, and give it a key
4) Reference it in the binding:
{Binding OrderDetails.OrderPaymentId,Converter={StaticResource MyConverter}}
|
|
|
|
|
Converter works:
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="MyBooleanToVisibilityConverter" />
</UserControl.Resources>
...
<Button Name="btnSomeButton" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" Click="btnSomeButton_Click" Width="40px" Height="40px" Visibility="{Binding Path=bIsVisible, ElementName=SomeControl, Mode=TwoWay}" >
<Image Source="..\Icons\SomeIcon.jpeg" ToolTip="SomeButton" />
</Button>
In above example, bIsVisible is a simple CLR property of type Boolean.
But as with any other "Enum", you do NOT need a converter, you could have binded a property of type "System.Windows.Visibility" directly to your control:
<Button Name="btnSomeCmd" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="3" Click="btnSomeCommand_Click" Width="40px" Height="40px" Visibility="{Binding Path=SomeButtonVisibility, ElementName=SomeControl, Mode=TwoWay, diagnostics:PresentationTraceSources.TraceLevel=High}" >
<Image Source="..\Icons\...; ToolTip="SomeCommand" />
</Button>
In above example, SomeButtonVisibility is a dependency property of type System.Windows.Visibility. I used a Dependency Property as supposed to a common CLR property only because I want take advantage of "Two Way" notification.
dev
|
|
|
|
|
You can try both the Solution given above. Both are perfect answer.
|
|
|
|
|
Hi All,
I have a wpf text box in which i am unable to press enter key, if i press its not doing anything,, actually i need if the user press enter button a new line should be inserted but its not happening..
do i need to do that in the Keydown event (finding the key pressed is enter)
or is there any other way. Please let me know.
Thanks in advance
|
|
|
|
|
|
Thanks Mr Kubajzz for your time and for your help.
I didnt set that property when i set that it works fine.
Thanks again
|
|
|
|
|
|
I am trying to build a sideways scrolling chart using SilverLight 3. I want to display multiple pieces of data that span a set of numerical values; however, the values are not parallel as they are in a bar chart that has a standard base value for each piece of data. Think of it as a Gantt chart with the top scale being zipcodes and the data being cities that contain the zipcodes. The data would be represented as a horizontal bar that spans a set of zipcodes. I actually looked into modifying a Gantt chart; however, since its primary function is to display data over a period of time, I am not certain if it will work.
Can anybody point me in a possible direction to solve my problem?
Using C# in SilverLight 3
Thanks for your time.
|
|
|
|
|
Do I need to add more information to make my needs a bit more clear?
|
|
|
|
|
How can we add toggle button in silverlight grid column?
|
|
|
|
|
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ToggleButton Grid.Row="0" Grid.Column="0" />
</Grid>
|
|
|
|
|
My application using 'Pages' and i using wpf navigation to navigate between the pages.
I cant to control the page size and the page location on the screen and i don't know how - because i don't see that there is option to setup the page container.
I see that the page himself has the edit option of width and height - but i want that the size will be as 'auto' mode - and i want to have the ability to use 'auto' of the size change ( case the user will change the page container size => the page size will be change automatically also )
|
|
|
|
|
I have set up the following tooltip to show the x and y values of datapoints within a WPF linechart, what I would also like to do is show the index within the collection that the point uses. How do I show this please?
<Style x:Key="ToolTipDataPointStyle" TargetType="chartingToolkit:LineDataPoint">
<Setter Property="Background" Value="Green"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Grid x:Name="Root" Opacity="1">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<ContentControl Content="{Binding HoleSize}" ContentStringFormat="Hole Size: {0}" />
<ContentControl Content="{Binding PulseWidth}" ContentStringFormat="Pulse Width: {0}"/>
<!--<ContentControl Content="{Binding Path.[0]}" ContentStringFormat="Data = {0}"/>-->
</StackPanel>
</ToolTipService.ToolTip>
<Ellipse StrokeThickness="{TemplateBinding BorderThickness}" Stroke="{TemplateBinding BorderBrush}" Fill="{TemplateBinding Background}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
|
|
|
|
|
Hi surfluds,
May be this link could help you.
http://endofstream.com/charts-creating-custom-style-for-linedatapoint/
|
|
|
|
|
I fancy expanding my Very Limited knowledge and would appreciate a link to an Idiots Guide in order to have a play around and maybe make a few basic attempts at prettiness.
Recommendations?
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
Silverlight or WPF? The choice is very dependent on the tech.
|
|
|
|
|
Silverlight.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
The truly wonderful Jesse Liberty has posted a set of tutorials here[^].
|
|
|
|
|
I thank you.
My weekend is sorted!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC League Table Link
CCC Link[ ^]
|
|
|
|
|
You are most welcome. Life is good right now - I'm writing a Silverlight app with the Dr Who episode "The Lodger" on in the background.
|
|
|
|
|
Depends. Do you intend to use Expression Blend[^]?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi,
I am trying to apply a style to a combo box but instead of getting applied the combo box itself disappears. Please check the following xaml code for user control.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
x:Class="Guardian.PAS.PASFramework.UI.WPF.PASComboBox"
xmlns:local="clr-namespace:Guardian.PAS.PASFramework.UI.WPF"
Height="26" Width="100" VerticalAlignment="Center" >
<UserControl.Resources>
<Style x:Key="comboBoxStyle" TargetType="{x:Type local:PASCustomComboBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:PASCustomComboBox}">
<ControlTemplate.Triggers>
<Trigger Property="local:PASCustomComboBox.IsEnabled" Value="false">
<Setter Property="Background" Value="Red"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Canvas Name="canvas" Height="23" Width="Auto" VerticalAlignment="Center">
<Label Height="23" Name="lblCaption" Width="20" VerticalAlignment="Center">aaa</Label>
<local:PASCustomComboBox Height="23" x:Name="cmbComboBoxControl" VerticalAlignment="Center" Width="50"
IsEditable="True" Style="{StaticResource comboBoxStyle}">
</local:PASCustomComboBox>
<Button Height="23" Name="btnSearch" Width="25" Click="btnSearch_Click" Visibility="Collapsed"
VerticalAlignment="Center">...</Button>
<Label Height="23" Name="lblDescription" VerticalAlignment="Center" Width="20" Foreground="Blue">
</Label>
</Canvas>
</UserControl>
Here PASCustomComboBox is a class which inherites from combo box.
public class PASCustomComboBox : ComboBox
{
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Down || e.Key == Key.Up)
{
e.Handled = true;
return;
}
base.OnPreviewKeyDown(e);
}
}
Please help!
Thanks in advance!
Regards,
Samar
|
|
|
|
|
When you set the Template property for a control, you're replacing the control with whatever is inside the template... In this case, you're replacing it with nothing, since the only thing you put inside your custom template is a trigger.
|
|
|
|
|
Oh... Then what should i write in the control template to show the current combo box as it is??? I am a little weak in xaml..!!
|
|
|
|
|
Don't use the Template unless you plan on replacing the entire control.
|
|
|
|