Skip to content

Commit

Permalink
Example code for Image
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Nov 5, 2024
1 parent 404a908 commit de30b70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
18 changes: 0 additions & 18 deletions source/iNKORE.UI.WPF.Modern.Gallery/ControlPages/ImagePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@
mc:Ignorable="d">
<StackPanel>
<local:ControlExample x:Name="Example1" HeaderText="A basic image from a local file.">

<Image
Height="100"
HorizontalAlignment="Left"
Source="/Assets/SampleMedia/treetops.jpg" />

<local:ControlExample.Xaml>
<sys:String>
&lt;Image Source=&quot;/Assets/SampleMedia/treetops.jpg&quot; Height=&quot;100&quot; /&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample x:Name="Example2" HeaderText="An image decoded to the rendering size">
Expand All @@ -33,17 +26,6 @@
<BitmapImage DecodePixelHeight="100" UriSource="/Assets/SampleMedia/treetops.jpg" />
</Image.Source>
</Image>

<local:ControlExample.Xaml>
<sys:String xml:space="preserve">
&lt;Image Height=&quot;100&quot;&gt;
&lt;Image.Source&gt;
&lt;BitmapImage UriSource=&quot;/Assets/SampleMedia/treetops.jpg&quot;
DecodePixelHeight=&quot;100&quot; /&gt;
&lt;/Image.Source&gt;
&lt;/Image&gt;
</sys:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample x:Name="Example3" HeaderText="Image stretching.">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ private void ImageStretch_Checked(object sender, RoutedEventArgs e)
var strStretch = (sender as RadioButton).Content.ToString();
var stretch = (Stretch)Enum.Parse(typeof(Stretch), strStretch);
StretchImage.Stretch = stretch;

UpdateExampleCode();
}
}

Expand All @@ -51,15 +53,39 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
});
ObservableCollection<ControlExampleSubstitution> Substitutions = new ObservableCollection<ControlExampleSubstitution>() { Substitution };
Example3.Substitutions = Substitutions;

UpdateExampleCode();
}

#region Example Code

public void UpdateExampleCode()
{

Example1.Xaml = Example1Xaml;
Example2.Xaml = Example2Xaml;
Example3.Xaml = Example3Xaml;
}

public string Example1Xaml => $@"
<Image Height=""100""
Source=""/Assets/SampleMedia/treetops.jpg"" />
";

public string Example2Xaml => $@"
<Image Height=""100"">
<Image.Source>
<BitmapImage DecodePixelHeight=""100"" UriSource=""/Assets/SampleMedia/treetops.jpg"" />
</Image.Source>
</Image>
";

public string Example3Xaml => $@"
<Image x:Name=""StretchImage""
Width=""100"" Height=""100""
Source=""/Assets/SampleMedia/valley.jpg""
Stretch=""{StretchImage.Stretch.ToString()}"" />
";

#endregion

}
Expand Down

0 comments on commit de30b70

Please sign in to comment.