2013年6月20日 星期四

[Windows 8] How to set TextBlock and TextBox to wrap in XAML

TextBlock and TextBox by setting TextWrapping = "Wrap" attribute to make the text exceeds the width of the control automatically wrap. The default is nowrap.
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top"/>


2013年6月18日 星期二

[Windows 8] How to check windows 8 UI modes by C#

Sample:

using Windows.UI.ViewManagement;

private void pageRoot_SizeChanged(object sender, SizeChangedEventArgs e)
{
    ApplicationViewState viewState = ApplicationView.Value;
    if (viewState == ApplicationViewState.Filled)
    {
        System.Diagnostics.Debug.WriteLine("viewState is Filled");
    }
    else if (viewState == ApplicationViewState.FullScreenLandscape)
    {
        System.Diagnostics.Debug.WriteLine("viewState is FullScreenLandscape");
    }
    else if (viewState == ApplicationViewState.Snapped)
    {
        System.Diagnostics.Debug.WriteLine("viewState is Snapped");
    }
    else if (viewState == ApplicationViewState.FullScreenPortrait)
    {
        System.Diagnostics.Debug.WriteLine("viewState is FullScreenPortrait");
    }
    else
    {
        System.Diagnostics.Debug.WriteLine("viewState is something unexpected");
    }
}

[Windows 8] How to create a circle mask image with XAML

The example creates an ImageBrush and sets the ImageSource to an image named people.png, which you must include as a resource in the app. The ImageBrush then paints the area defined by an Ellipse shape.
<Ellipse Height="200" Width="200"> 
    <Ellipse.Fill> 
        <ImageBrush ImageSource="people.png" /> 
    </Ellipse.Fill> 
</Ellipse>

Result:

Reference:
Quickstart: Using brushes (Windows Store apps using C#/VB/C++ and XAML)

2013年6月4日 星期二

[DirectX] Solution: Error code S1023 installing DirectX SDK on Windows 7

The solution:
1. Remove the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1) from the system (both x86 and x64 if applicable). This can be easily done via a command-line with administrator rights:
    MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
    MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}

2. Install the DirectX SDK (June 2010)

3. Reinstall the Visual C++ 2010 Redistributable Package version 10.0.40219 (Service Pack 1). On an x64 system, you should install both the x86 and x64 versions of the C++ REDIST. Be sure to install the most current version available, which at this point is the KB 2565063 with a security fix.

Reference:
Known Issue: DirectX SDK (June 2010) Setup and the S1023 error