Posts Tagged ‘wpf’

How do I change an image on hover over in WPF? – Stack Overflow

 

<Style.Triggers>
	<Trigger Property="IsMouseOver" Value="True">
	  <Setter Property="Source" Value="C:\Image2.jpg"/>
	</Trigger>
</Style.Triggers>

 

via How do I change an image on hover over in WPF? – Stack Overflow.

Finding control within WPF itemscontrol – Stack Overflow

via Finding control within WPF itemscontrol – Stack Overflow.

The SO community is lovely! This one is another example to be one of the lively & helpful content you can find here!

Using the WPF Visualizer to debug applications in Visual Studio 2010

via Using the WPF Visualizer to debug applications in Visual Studio 2010 – Habib Heydarian’s Blog @ Microsoft – Site Home – MSDN Blogs.

In Visual Studio 2010, you can use the WPF visualizer to inspect the details of the entire WPF application. To do that, once you are stopped in the debugger, open Watch or Locals window and click on the magnifying glass next to the WPF control. In this case, I’m using the visualizer on the Flipper3DTransition control.


When the WPF visualizer opens, you will see a screen similar to the one below…

(Please see the full article in the reference listed above)

How to get the code-generation of `.resx` resource file back-to-work?

Hi everyone,

Normally when we add new rows to a .resx file, say Resources.resx, in the IDE’s resource editor, the code-behind file, say Resources.Designer.cs, will be automatically updated – adding new properties for the new rows.

But in some situation, that automation job stops working!? Then, how can we re-activate the IDE so that the .resx’s code-behind return to work?

Here what I found:

  1. Delete the Resources.Designer.cs file
  2. In Solution Explorer, exclude the Resources.resx
  3. Then, show all files, re-include the Resources.resx. The Resources.Designer.cs file should be recreated then.
  4. Reset the ‘Access Modifier’ to be ‘Public’
  5. Right click Resources.resx in Solution Explorer and click Run custom tool

Hope this would be helpful to you!

Nam

ps. You can see my discussion on SO here.

How to set a value to display for bound properties in WPF design mode? – Stack Overflow

via How to set a value to display for bound properties in WPF design mode? – Stack Overflow

An easy way to get Design-time-data in Visual Studio 2010 is to use a design-datacontext.

Short example with a Window and a ViewModel, For DataContext, the d:DataContext will be used in Design-mode and the StaticResource will be used in runtime. You can also use a separate ViewModel for design but in this example I will use the same ViewModel for both.

<Window ...
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:TheNamespaceContainsTheDesignModeViewModel;assembly=TheAssemblyOrProjectContainsYourViewModelClass"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance local:YourDesignModeViewModel, IsDesignTimeCreatable=True}">
    <Window.Resources>
        <local:MyViewModel x:Key="MyViewModel" />
    </Window.Resources>
    <Window.DataContext>
        <StaticResource ResourceKey="MyViewModel"/>
    </Window.DataContext>
    <StackPanel>
        <TextBox Text="{Binding MyText}"
                 Width="75"
                 Height="25"
                 Margin="6"/>
    </StackPanel>
</Window>

Hope this is helpful!

Nam.

Shared Sizes between WPF Grid Columns/Rows

via WPF Grid Shared Size Groups – Guy

Normal Grid:


Column 2 width set by column 1 width of the same grid:


Column 2 width at grid 2 is set by column 1 width of grid 1:


You may reuse the shared size group in multiple columns or rows at multiple grids.

Please pay attention to the fact that the share size group is set both ways, that means that the size of all shared column (or rows) is set by the largest column (or row).

Sharing a group can be done by simply setting the ColumnDefinition‘s SharedSizeGroupproperty to a specific name that will be also used at the other’s column’s definition.

<Grid Grid.Row=”0″Background=”AliceBlue”  ShowGridLines=”True”>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=”Auto”SharedSizeGroup=”ShareThis“></ColumnDefinition>
<ColumnDefinition Width=”Auto”></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

….

<Grid Grid.Row=”2″ Background=”AntiqueWhite”  ShowGridLines=”True”>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=”Auto” SharedSizeGroup=”ShareThis“></ColumnDefinition>
<ColumnDefinition Width=”Auto” ></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>

One last thing to do is to set the scope of the shared size group in the current window, this can be done by setting Grid.IsSharedSizeScope property to true at a container whose scope encompasses the shared columns/rows.

<Grid Grid.IsSharedSizeScope=”True” >

You can view a sample code here

How can I restart WPF application?? – Stack Overflow

RestartIf there is a possibility to directly restart the app, I dont know. What you can try is to use App.Current.Shutdown to close the app and start a new instance through System.Diagnostics.Process.Start where the path to the app can be taken from System.Reflection.Assembly.GetEntryAssembly. `.

via How can I restart WPF application?? – Stack Overflow.