Reputation: 6894
Anyone got any neat solutions to prevent a Silverlight ChildWindow being moved?
thanks, Mark
Upvotes: 0
Views: 1523
Reputation: 11
Not Required to Create new class, instead
Copy the style from: http://msdn.microsoft.com/en-us/library/dd833070%28VS.95%29.aspx
Give x:key="stylename"
In Construtor of Childwindow
, paste following code before InitializeComponent
:
this.Style = App.Current.Resources["childWindow"] as Style;
above solution resolved my issue
Upvotes: 1
Reputation: 65
Maybe you can try this simple way to do that: Create a Grid to warp all the content in your ChildWindow.
<Grid Margin="0">
<!--Your ChildWindow. Canvas, Grid, Textblock...Whatever-->
</Grid>
Since the Grid has a 0 margin, you can not click it and move it.
Upvotes: 0
Reputation: 189485
I'm not sure you'd call this neat but...
ImmovableChildWindow
. ChildWindow
.ImmoveableChildWindow
ImmovableChildWindow
style.TargetType
for this copy to the same value as the exiting ImmovaleChildWindow
style.ImmovableChildWindow
.Template
setter change the TargetType
of to the same value as the style TargetType
Border
with the name Chrome. Delete the x:Name="Chrome"
attribute. (This is what we are really after).Now when you create a new ChildWindow item it will by default inherit form ChildWindow
, if you want it to be immovable you need modify it to inherit from ImmovableChildWindow
instead (change the base type in the code-behind and the root tag name in the xaml).
The ChildWindow
attaches events to the FrameWorkElement
with the name "Chrome" which enables the child window to be moved about. However being a well-behaved templated control, if it can't find a FrameworkElement
called "Chrome" it just continues to work without that feature.
Upvotes: 1