|
The reason I was doing that is because I thought WPF was smart enough to make the call. Afterall, setting Label.Content in CS or in XAML can be done like so:
Label.Content = "my string";
<Label Content="my string" />
In both instances, the Content property is *still* a ContentControl .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Actually, it's not. Looking in the object browser shows that the Content property is of type Object . Perhaps you are thinking of how the Content property is *on* ContentControl ?
|
|
|
|
|
Yeah, I found that out. I changed it all to object , and it worked.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I want to apply "Css" for Silverlight image control.I am having one silverlight image control in that left button down event i have to open asp.net form.For that aspx page i want to apply styles while opening that page.In left button down event i am calling java script function to call that aspx page.But from where i have to apply styles to open that page.
If i use anchor tag to open popup window in normal aspx page I can use the following line to work it properly.
<a style="font-family:Verdana; font-size:12px; font-weight:bold; text-decoration:none; color:#ffffff;" href="Contactus.aspx?TB_iframe=true&height=500&width=600" class="thickbox">Contact us</a>
Here I am using class="thickbox" css class.
But for now i want to open popup from code behind for that i have written following code in silverlight image control code behind.
HtmlPage.Window.Invoke("login");
And I am calling that javascript function in aspx page like this.
<script type="text/javascript">
function login() {
var url = "http://219.91.199.132/Gateway/Login.aspx";
window.open(
"UserLogin.aspx", 'window', 'width=630,height=620,background=silver,menubar=no, resizable=no')
}
</
script>
Can anyone please help me how to apply css for silverlight controls.
Thanks in advance
Pavani
|
|
|
|
|
CSS has nothing to do with Silverlight.
Try asking on the Web Development board
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
As mentioned, there is no CSS styling to Silverlight controls as they are rendered inside the "Silverlight sandbox" in the browser.
If you are looking to have a way to style controls, you should look at the Style element for your purposes. This allows you to create generic styles and then apply them to your controls, sort of the Silverlight "CSS equivalent."
|
|
|
|
|
One hack is to use 'initParams' to send these style values to silverlight control. There, you convert them into styles and apply them.
|
|
|
|
|
Hi,
My scenario is like this.
1. I will get the language setting from my settings file.
2. I need to display my control text based on the language setting either in English or other language.
Is it possible to prepare a conditional XAML for the same scenario.
For example:
Can i set the content based on some setting for the Template below
Thanks
|
|
|
|
|
|
Hi,
I have a DatePicker, where I set the CalendarStyle (I'm using mvvm). The issue is, when I select a day on the calender, nothing happens (Looks like the Click event just never fires, or something.)
The Control looks as follow:
<tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" CalendarStyle="{DynamicResource CalenderStyleNew}"></tool:DatePicker>
Where the style looks as follow:
<Style TargetType="Controls:Calendar" x:Key="CalenderStyleNew">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Controls:Calendar">
<StackPanel HorizontalAlignment="Center" x:Name="Root">
<Controls:Calendar x:Name="Calendar" SelectedDate="{TemplateBinding SelectedDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Controls:Calendar.CalendarDayButtonStyle>
<Style>
<Setter Property="Button.Height" Value="50"></Setter>
<Setter Property="Button.Width" Value="50"></Setter>
<Setter Property="Button.FontSize" Value="20"></Setter>
</Style>
</Controls:Calendar.CalendarDayButtonStyle>
<Controls:Calendar.CalendarButtonStyle>
<Style>
<Setter Property="Button.Height" Value="50"></Setter>
<Setter Property="Button.Width" Value="50"></Setter>
<Setter Property="Button.FontSize" Value="20"></Setter>
</Style>
</Controls:Calendar.CalendarButtonStyle>
</Controls:Calendar>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I need the buttons bigger, because it's a touch screen app... Test this in your app, and you'll see, nothing happens when you select a day...
Any help would be much appreciated.
Kind regards,
Hugo
|
|
|
|
|
ok, after A LOT of struggling, I managed to make a work around... but, it's not pretty !!! An easier solution would be much appreciated.
What I did, was the following:
<Controls:DatePicker Grid.Column="1" Grid.Row="6" SelectedDate="{Binding BirthDate}" ViewModels:EmployeeViewModel.DatePickerGotFocus="{Binding}">
<Controls:DatePicker.CalendarStyle>
<Style TargetType="Controls:Calendar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Controls:Calendar">
<StackPanel HorizontalAlignment="Center" x:Name="Root">
<Controls:Calendar x:Name="Calendar" ViewModels:EmployeeViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Controls:Calendar.CalendarDayButtonStyle>
<Style>
<Setter Property="Button.Height" Value="50"></Setter>
<Setter Property="Button.Width" Value="50"></Setter>
<Setter Property="Button.FontSize" Value="20"></Setter>
</Style>
</Controls:Calendar.CalendarDayButtonStyle>
<Controls:Calendar.CalendarButtonStyle>
<Style>
<Setter Property="Button.Height" Value="50"></Setter>
<Setter Property="Button.Width" Value="50"></Setter>
<Setter Property="Button.FontSize" Value="20"></Setter>
</Style>
</Controls:Calendar.CalendarButtonStyle>
</Controls:Calendar>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Controls:DatePicker.CalendarStyle>
</Controls:DatePicker>
Then I made attached properties for the DatePicker and Calendar as follow:
private Calendar _calender;
private DatePicker _datePicker;
public static object GetDatePickerGotFocus(DependencyObject obj)
{
return (object)obj.GetValue(DatePickerGotFocusProperty);
}
public static void SetDatePickerGotFocus(DependencyObject obj, object value)
{
obj.SetValue(DatePickerGotFocusProperty, value);
}
public static readonly DependencyProperty DatePickerGotFocusProperty =
DependencyProperty.RegisterAttached("DatePickerGotFocus", typeof(object), typeof(EmployeeViewModel), new UIPropertyMetadata(OnDatePickerGotFocus));
private static void OnDatePickerGotFocus(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
DatePicker datePicker = d as DatePicker;
EmployeeViewModel model = e.NewValue as EmployeeViewModel;
if (datePicker != null && model != null)
{
model._datePicker = datePicker;
}
}
public static object GetOnCalenderLoaded(DependencyObject obj)
{
return (object)obj.GetValue(OnCalenderLoadedProperty);
}
public static void SetOnCalenderLoaded(DependencyObject obj, object value)
{
obj.SetValue(OnCalenderLoadedProperty, value);
}
public static readonly DependencyProperty OnCalenderLoadedProperty =
DependencyProperty.RegisterAttached("OnCalenderLoaded", typeof(object), typeof(EmployeeViewModel), new UIPropertyMetadata(OnCalenderLoaded));
private static void OnCalenderLoaded(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Calendar calendar = d as Calendar;
EmployeeViewModel model = e.NewValue as EmployeeViewModel;
if (calendar != null && model != null)
{
model._calender = calendar;
}
}
And then I set the visibility as follows:
public DateTime _birthDate;
public DateTime BirthDate
{
get { return _birthDate; }
set
{
_birthDate = value;
OnPropertyChanged("BirthDate");
if (_calender != null)
{
_calender.Visibility = Visibility.Hidden;
_datePicker.GotFocus += new RoutedEventHandler(_datePicker_GotFocus);
}
}
}
private void _datePicker_GotFocus(object sender, RoutedEventArgs e)
{
_calender.Visibility = Visibility.Visible;
etc..
|
|
|
|
|
lol, I over complicated this a bit. The final solution I made was as follow:
<tool:DatePicker Grid.Column="1" Grid.Row="8" SelectedDate="{Binding BirthDate}" ViewModels:PatronViewModel.DatePickerGotFocus="{Binding}" Height="34" FontSize="18">
<tool:DatePicker.LayoutTransform>
<ScaleTransform ScaleY="1.5" ScaleX="1.5"></ScaleTransform>
</tool:DatePicker.LayoutTransform>
<tool:DatePicker.CalendarStyle>
<Style TargetType="tool:Calendar">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="tool:Calendar">
<StackPanel HorizontalAlignment="Center" x:Name="Root">
<tool:Calendar x:Name="Calendar" ViewModels:PatronViewModel.OnCalenderLoaded="{Binding}" SelectedDate="{Binding BirthDate}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<tool:Calendar.LayoutTransform>
<ScaleTransform ScaleX="2" ScaleY="2"></ScaleTransform>
</tool:Calendar.LayoutTransform>
</tool:Calendar>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</tool:DatePicker.CalendarStyle>
</tool:DatePicker>
So by simply scaling the DatePicker, I got a cool touch screen DatePicker....
|
|
|
|
|
I tried your code above. For some reason, when I select a date from the calendar popup, it doesn't close the popup or select a date. I removed all Bindings since I don't have a viewmodel. I am just trying this out before putting it in my project.
|
|
|
|
|
I remember having this problem.... I had to do some magic on the actual date time by hiding and showing the actual boxes....
|
|
|
|
|
I have the same problem (selecting date does nothing and I am not using view model) I was hoping you could elaborate on the "magic" that you used to resolve this problem. Thanks.
|
|
|
|
|
You don't even want to know what I had to do to fix this !!!! It's INSANE !
|
|
|
|
|
hi bonkers,
i thank you very much!!!!.
your snippet helps me to solve my DatePicker SelectedDate - Binding problem!
here is my solution. just override the ControlTemplate of the DatePicker-Control and bind the SelectedDate of the PopupCalendar.
<Popup Name="Part_CalendarPopup"
Margin="0,22,-22,-12"
HorizontalAlignment="Right"
PlacementTarget="{Binding ElementName=Part_CalendarButton}" StaysOpen="False">
<Grid Name="Part_CalendarGrid" Background="White">
<cal:Calendar
SelectedDate="{Binding SelectedDate, Mode=TwoWay}" <!-- the holy line -->
Height="160" Width="160"
FooterVisibility="Collapsed" WeekColumnVisibility="Collapsed"
FontSize="9"/>
</Grid>
</Popup>
|
|
|
|
|
Hi.. Inside my code the combobox is not responding to key press events.. like if user presses M, combobox should select Marrylands in the dropdownlist like the ASP .net combobox does. Can anyone please help???
<ComboBox HorizontalAlignment="Right" Height="23" Name="cmbPortsFrom" KeyDown="cmbPortsFrom_KeyDown" Width="105" SelectedIndex="0" Grid.Row="2" Grid.Column="0" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Code}" FontSize="15" Height="20"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
codebehind:
Dim lDataSource2 As ICollection(Of BusinessLayer.Ports)
lDataSource2 = mBalObjPorts.getPortData()
Me.cmbPortsFrom.ItemsSource = lDataSource2
|
|
|
|
|
SR81 wrote: KeyDown="cmbPortsFrom_KeyDown"
What are you doing in the keydown event ?
|
|
|
|
|
apparently nothing, its an empty function.I believe the combobox should automatically select Marrylands from the list if user presses "M" key??
|
|
|
|
|
Perhaps your empty event is preventing this from occuring ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I have removed the function, still its not working.
It could be because the combobox contains nearlly 500 rows?
Anyhow i am writing the keypress event function to achieve this. Thanks.
|
|
|
|
|
SR81 wrote: It could be because the combobox contains nearlly 500 rows?
That doesn't seem logical.
Perhaps because changes to VisualTree will be making it difficult to decide what to use as SelectedValuePath. Just a guess.
|
|
|
|
|
If you are going to use a just a TextBox then do it this way,
<ComboBox x:Name="myComboBox" IsEditable="true" DisplayMemberPath="Code" Height="266" >
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
If no, you would have to implement the functionality on KeyDown event (specifically by overriding OnPreviewKeyDown). This[^] might be of help.
|
|
|
|
|
Thanks,that just gave me an idea of creating an AJax listsearch extender kind of control in WPF. Cheers
|
|
|
|