silverlight

MainWindow.Closing event not always raised in Silverlight 4 OOB app

和自甴很熟 提交于 2020-01-23 06:09:12
问题 I've made a rather complex Silverlight 4 out-of-browser application. One of my main view models adds an event handler to the Application.Current.MainWindow.Closing event. This works fine when the application is initially run. It is able to cancel the close operation. However, sometimes after performing operations like showing and closing a ChildWindow, the MainWindow's Closing event is no longer calling my handler. In the debugger, I added a watch to the MainWindow's underlying closing event

How to enable enter button on keyboard on wp7?

走远了吗. 提交于 2020-01-23 01:20:10
问题 I was noticing on certain application for wp7, that they were able to use the enter key on the keyboard to submit, but by default when you hit the enter key it goes to the next line. I was even noticing the enter key is different from the default enter key. How do you submit, and if possible how do you change the way the enter key looks? Any tips, answers or resources would be appreciated. Thanks. 回答1: You need to change the InputScope from "Text" and then capture the enter key on the KeyDown

Windows Phone 7 Hiding the Application Bar

北城余情 提交于 2020-01-22 17:42:48
问题 I would like to be able to press a button to disable the menu bar in my application. If you go menubar.IsVisible = false; it throws a null reference exception. The menu bar is declared in XAML. Anyone know if its possible to hide it on the fly like this? 回答1: You can access this as a static member on ApplicationBar. i.e. ApplicationBar.IsVisible = true/false; Some background here on why ApplicationBar doesn't play like normal silverlight elements. Why are the ApplicationBar objects not

How to represent Line Break or new line in silverlight textBox

爷,独闯天下 提交于 2020-01-22 05:18:04
问题 I am having hard time to match Special characters set in Silverlight. I only on the following: To represent a LineBreak in Silverlight TextBlock: use : > lineBreak < But What do I use to represent a New Line or LineBreak In Silverlight TextBox?? Example : I want this one line mag : This is line one. This is line two into this : This is line one. This is line two. it seems this \r\n is not working. This is line one \r\n 回答1: The bottom line at the top <TextBox Text="This is line one! This is

Independent width in a WPF Grid

夙愿已清 提交于 2020-01-22 00:38:46
问题 I have a grid with 2 rows and 2 columns in WPF. I would like that the column widths are independent for each row. I tried "auto", but no success. Here is a picture in order to explain: How can I accomplish this using grid? 回答1: If you must use a grid layout, then you have a couple of options: Option 1: Make each row a single column and then nest a grid in each row you would like independent columns: XAML <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions>

Independent width in a WPF Grid

可紊 提交于 2020-01-22 00:38:11
问题 I have a grid with 2 rows and 2 columns in WPF. I would like that the column widths are independent for each row. I tried "auto", but no success. Here is a picture in order to explain: How can I accomplish this using grid? 回答1: If you must use a grid layout, then you have a couple of options: Option 1: Make each row a single column and then nest a grid in each row you would like independent columns: XAML <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions>

Border disappearing on ItemsControl resize (using “stretchpanel”)

倾然丶 夕夏残阳落幕 提交于 2020-01-21 19:32:26
问题 Yesterday I asked how to get an ItemsControl to have its children equally distributed across the available space; and after happily reading the answer, I wrote (well actually kind of copied and adjusted it) my own "stretchpanel", which does exactly what i want. However my children are supposed to have a border on their right side, which works, as long as the child is bigger than its content. As soon as it gets smaller the border disappears and i can't tell why (and thus, not fix it). Below

Border disappearing on ItemsControl resize (using “stretchpanel”)

Deadly 提交于 2020-01-21 19:31:25
问题 Yesterday I asked how to get an ItemsControl to have its children equally distributed across the available space; and after happily reading the answer, I wrote (well actually kind of copied and adjusted it) my own "stretchpanel", which does exactly what i want. However my children are supposed to have a border on their right side, which works, as long as the child is bigger than its content. As soon as it gets smaller the border disappears and i can't tell why (and thus, not fix it). Below

Why does System.Windows.Controls.Button always have a padding of 10px?

最后都变了- 提交于 2020-01-21 12:20:53
问题 See screenshot. The bounding cyan-bordered box is the button, while the blue fill is the rectangle. I cannot for the life of me figure out how to get rid of the padding in the button. Is there a way to position the rectangle to the top left so it touches the cyan border? Thanks. 回答1: Did you try setting the Rectangle 's margin to 0 ? <Button x:Name="Button" BorderThickness="0" Margin="0" Padding="0" Width="96" Height="96"> <Rectangle Fill="Blue" Margin="0" Width="96" Height="96" /> </Button>

Close childwindows in silverlight with a click outside of it

巧了我就是萌 提交于 2020-01-21 08:54:25
问题 How can I close a childwindow when I click outside of it? 回答1: if you are using the default silverlight child window style, when it opens, the outside part (the transparent grey part) is actually a Grid (called Overlay) that is within the child window style. So what you need to do is to handle its MouseLeftButtonDown event, <Grid x:Name="Overlay" Background="{TemplateBinding OverlayBrush}" HorizontalAlignment="Stretch" Margin="0" Opacity="{TemplateBinding OverlayOpacity}" VerticalAlignment=